Altova Mailing List Archives


Re: [xsl] Getting the name the input data document

From: Jingjun Long <longjingjun@-----.--->
To: xsl-list@-----.------------.---
Date: 8/21/2009 3:03:00 AM
Hello,

I tried to use base-uri to get XML path and static-base-uri to get XSL
path. This works find when I run the transformation from XML file and
XSL file locate on the hard disk.

When I run the transformation against XML which generate on the fly by
a program. The base-uri function return empty. From the implementation
point of view there is no base-uri for a XML which generated on the
fly.

Jingjun


2009/8/21 Mark Wilson <mark@k...>
>
> As always Ken, you are more than helpful.
> Thanks,
> Mark
>
> --------------------------------------------------
> From: "G. Ken Holman" <gkholman@C...>
> Sent: Thursday, August 20, 2009 6:27 PM
> To: <xsl-list@l...>
> Subject: Re: [xsl] Getting the name the input data document
>
>> I just remembered that isn't the only way ... you can also use base-uri():
>>
>> t:\ftemp>xslt2 mark.xml mark.xsl
>>
>> Filename: file:/t:/ftemp/mark.xml
>> Alternate: file:/t:/ftemp/mark.xml
>> t:\ftemp>type mark.xsl
>> <?xml version="1.0" encoding="US-ASCII"?>
>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>                version="2.0">
>>
>> <xsl:output method="text"/>
>>
>> <xsl:template match="/">
>> Filename: <xsl:value-of select="document-uri(/)"/>
>> Alternate: <xsl:value-of select="base-uri(/)"/>
>> </xsl:template>
>>
>> </xsl:stylesheet>
>> t:\ftemp>
>>
>>
>> At 2009-08-20 21:22 -0400, I wrote:
>>>
>>> At 2009-08-20 18:18 -0700, Mark Wilson wrote:
>>>>
>>>> I've poked around, but suspect I am searching for the wrong terms in the index to Michael's XML/XPath book. I found one reference on the web that said what I want to do could not be done with XSLT 1.0.
>>>
>>> You can do it for the stylesheet in XSLT 1.0 but not for the data file.
>>>
>>>> However, I am using XSLT 2.0.
>>>
>>> Not a problem.
>>>
>>>> I need to know the file name of the file my XSLT style sheet is acting upon so that I can write it out as part of the tile of an XSL-FO output PDF document. Does XSLT 2.0 have a way of getting the file name?
>>>
>>> The document-uri() function is what you need.
>>>
>>> I hope the example below helps.
>>>
>>> . . . . . . . . Ken
>>>
>>> t:\ftemp>xslt2 mark.xml mark.xsl
>>>
>>> Filename: file:/t:/ftemp/mark.xml
>>> t:\ftemp>type mark.xsl
>>> <?xml version="1.0" encoding="US-ASCII"?>
>>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>>                version="2.0">
>>>
>>> <xsl:output method="text"/>
>>>
>>> <xsl:template match="/">
>>> Filename: <xsl:value-of select="document-uri(/)"/>
>>> </xsl:template>
>>>
>>> </xsl:stylesheet>
>>> t:\ftemp>
>>
>>
>> --
>> Interested in these classes?  http://www.CraneSoftwrights.com/s/i/
>> Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
>> Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
>> Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
>> Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
>> G. Ken Holman                 mailto:gkholman@C...
>> Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
>> Legal business disclaimers:  http://www.CraneSoftwrights.com/legal
>>
>>
>> --~------------------------------------------------------------------
>> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
>> or e-mail: <mailto:xsl-list-unsubscribe@l...>
>> --~--
>>
>>
>>
>
>
> --~------------------------------------------------------------------
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@l...>
> --~--
>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@l...>
--~--

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.