Problem using document-uri()

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem using document-uri()

Christian Mahnke-2
Hi,
I might be missing something, but it seem to me that the document-uri() function is broken in the Saxon release shipped with Oxygen 15.1, haven’t checked the older versions:

If I run the following line to transform the attached files, document-uri() doesn’t work every time:
java -cp /Applications/Oxygen\ 15.1/lib/saxon9ee.jar com.saxonica.Transform  empty.xml test.xsl input-collection=./xml-files/

The expected output for each file is:
Processing file file:/Users/cmahnke/Desktop/saxon-document-uri/xml-files/3.xml
Document is: file:/Users/cmahnke/Desktop/saxon-document-uri/xml-files/3.xml

Actual output:
Processing file file:/Users/cmahnke/Desktop/saxon-document-uri/xml-files/3.xml
Document is:


Any explanation?


Best,
Christian


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 

saxon-document-uri.zip (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem using document-uri()

Christian Mahnke-2
Hi again,
I’ve found the reason already, it only works for document nodes:
http://www.w3.org/TR/xpath-functions/#func-document-uri

I’ll try to make up an function that tries to solve this, It should work if I walk the list of ancestors until I find a document node, right?

Christian

Am 22.11.2013 um 19:51 schrieb Christian Mahnke <[hidden email]>:

> Hi,
> I might be missing something, but it seem to me that the document-uri() function is broken in the Saxon release shipped with Oxygen 15.1, haven’t checked the older versions:
>
> If I run the following line to transform the attached files, document-uri() doesn’t work every time:
> java -cp /Applications/Oxygen\ 15.1/lib/saxon9ee.jar com.saxonica.Transform  empty.xml test.xsl input-collection=./xml-files/
>
> The expected output for each file is:
> Processing file file:/Users/cmahnke/Desktop/saxon-document-uri/xml-files/3.xml
> Document is: file:/Users/cmahnke/Desktop/saxon-document-uri/xml-files/3.xml
>
> Actual output:
> Processing file file:/Users/cmahnke/Desktop/saxon-document-uri/xml-files/3.xml
> Document is:
>
>
> Any explanation?
>
>
> Best,
> Christian
>
> <saxon-document-uri.zip>


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Problem using document-uri()

G. Ken Holman
In reply to this post by Christian Mahnke-2
At 2013-11-22 19:51 +0100, you wrote:
>I might be missing something, but it seem to me that the
>document-uri() function is broken ... document-uri() doesn't work every time:
>...
>Any explanation?

I haven't looked at your code, but did you remember that the argument
to document-uri() requires a *root* node and not just any node?  That
is something I find I have to remind my students.

I hope this helps.

. . . . . . . . Ken


--
Public XSLT, XSL-FO, UBL & code list classes: Melbourne, AU May 2014 |
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/z/ |
G. Ken Holman                   mailto:[hidden email] |
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Problem using document-uri()

G. Ken Holman
In reply to this post by Christian Mahnke-2
At 2013-11-22 22:01 +0100, Christian Mahnke wrote:
>Hi again,
>I've found the reason already, it only works for document nodes:
>http://www.w3.org/TR/xpath-functions/#func-document-uri
>
>I'll try to make up an function that tries to solve this, It should
>work if I walk the list of ancestors until I find a document node, right?

Or just use:  document-uri(root(.))

. . . . . . . Ken


--
Public XSLT, XSL-FO, UBL & code list classes: Melbourne, AU May 2014 |
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/z/ |
G. Ken Holman                   mailto:[hidden email] |
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Problem using document-uri()

Graydon
Or base-uri(.)

Or if you want the _executable_ uri, static-base-uri()


On Fri, Nov 22, 2013 at 4:06 PM, G. Ken Holman <[hidden email]> wrote:
At 2013-11-22 22:01 +0100, Christian Mahnke wrote:
>Hi again,
>I've found the reason already, it only works for document nodes:
>http://www.w3.org/TR/xpath-functions/#func-document-uri
>
>I'll try to make up an function that tries to solve this, It should
>work if I walk the list of ancestors until I find a document node, right?

Or just use:  document-uri(root(.))

. . . . . . . Ken


--
Public XSLT, XSL-FO, UBL & code list classes: Melbourne, AU May 2014 |
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/z/ |
G. Ken Holman                   mailto:[hidden email] |
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Problem using document-uri()

Michael Kay
In reply to this post by G. Ken Holman

On 22 Nov 2013, at 21:06, G. Ken Holman <[hidden email]> wrote:

> At 2013-11-22 22:01 +0100, Christian Mahnke wrote:
>> Hi again,
>> I've found the reason already, it only works for document nodes:
>> http://www.w3.org/TR/xpath-functions/#func-document-uri
>>
>> I'll try to make up an function that tries to solve this, It should
>> work if I walk the list of ancestors until I find a document node, right?
>
> Or just use:  document-uri(root(.))
>

Or just document-uri(/)

Michael Kay
Saxonica


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Problem using document-uri()

G. Ken Holman
In reply to this post by Graydon
At 2013-11-22 16:27 -0500, Graydon Saunders wrote:
>Or base-uri(.)
>
>Or if you want the _executable_ uri, static-base-uri()

Actually, base-uri(.) will only return the same value in a monolithic
input XML document.  If you are using external parsed general
entities and the node is in an external entity, base-uri(.) will give
you the URI of the external entity.  I know external parsed general
entities are not widely used, but you cannot control your users'
input fragmentation.

The static-base-uri() returns the base-uri of the entity in which the
stylesheet node is found that has the static-base-uri() invocation expression.

I think root(.) is unambiguously the best bet for document-uri().

I hope this comment is considered supportive.

. . . . . . . Ken


--
Public XSLT, XSL-FO, UBL & code list classes: Melbourne, AU May 2014 |
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/z/ |
G. Ken Holman                   mailto:[hidden email] |
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Problem using document-uri()

Michael Kay

On 22 Nov 2013, at 21:34, G. Ken Holman <[hidden email]> wrote:

> At 2013-11-22 16:27 -0500, Graydon Saunders wrote:
>> Or base-uri(.)
>>
>> Or if you want the _executable_ uri, static-base-uri()
>
> Actually, base-uri(.) will only return the same value in a monolithic
> input XML document.  If you are using external parsed general
> entities and the node is in an external entity, base-uri(.) will give
> you the URI of the external entity.

base-uri() and document-uri() may also differ if the document contains xml:base attributes,
and probably under some other circumstances as well, e.g. if the URI used to request a document using document() is different from the URI that comes back in the SystemID property of the returned Source object.

Michael Kay
Saxonica
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help