Project

Profile

Help

Bug #2409

closed

Document URI property is not transferred to the second stylesheet when using the saxon:next-in-chain extension

Added by Radu Pisoi over 9 years ago. Updated almost 7 years ago.

Status:
Won't fix
Priority:
Low
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2015-06-25
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

The document URI of the source XML document is not available in chaining transformations when using the saxon:next-in-chain extension.

The next XSLT code from the stylesheet pointed by the saxon:next-in-chain attribute:

<xsl:variable name="docURI" select="document-uri(/)"/>
<xsl:message>Document URI: '<xsl:value-of select="$docURI"/>'</xsl:message>

will produce the next message:

Document URI: ''.

If I run the same stylesheet with Saxon 9.5.1.7 I get the expected result:

[Saxon-PE] Document URI: file:/D:/workspace/eXml/test/EXM-33883/res1.xml

Command line to reproduce the issue:

D:\workspace\eXml>java -Xmx60m -cp lib/saxon9ee.jar net.sf.saxon.Transform -s:file:instance.xml -xsl:main.xsl -o:result.xml

Files

instance.xml (59 Bytes) instance.xml Radu Pisoi, 2015-06-25 11:25
main.xsl (433 Bytes) main.xsl Radu Pisoi, 2015-06-25 11:25
second.xsl (796 Bytes) second.xsl Radu Pisoi, 2015-06-25 11:25
Actions #1

Updated by Michael Kay over 9 years ago

I get a blank document URI whether I run this under 9.5 or 9.6.

I don't see how it can be otherwise. The input to the second stylesheet is an in-memory document that does not exist on disk and cannot be retrieved by any call on the doc() function. How can it have a document URI?

In your example, where does the name file:/D:/workspace/eXml/test/EXM-33883/res1.xml come from? Is this the name of some existing file? Does the file actually contain the document that is the input to the second stylesheet?

Actions #2

Updated by Radu Pisoi over 9 years ago

In your example, where does the name file:/D:/workspace/eXml/test/EXM-33883/res1.xml come from? Is this the name of some existing file? Does the file actually contain the document that is the input to the second stylesheet?

The 'file:/D:/workspace/eXml/test/EXM-33883/res1.xml' path is the URI of the output file.

Next, I will append the output of the transformations with 9.5 and 9.6:

With Saxon 9.5:

C:\Users\radu_pisoi\Desktop\test-saxon-next-chain>java -Xmx60m -cp saxon_9_5/saxon9ee.jar net.sf.saxon.Transform
No source file name
Saxon-EE 9.5.1.7J from Saxonica
Usage: see http://saxonica.com/documentation/html/using-xsl/commandline.html
Format: net.sf.saxon.Transform options params
Options available: -? -a -catalog -config -cr -dtd -expand -explain -ext -im -init -it -l -m -now -o -opt -or -outval -p -quit -r -repeat -s -sa -strip -t -T -t
hreads -TJ -TP -traceout -tree -u -val -versionmsg -warnings -x -xi -xmlversion -xsd -xsdversion -xsiloc -xsl -xsltversion -y
Use -XYZ:? for details of option XYZ
Params:
  param=value           Set stylesheet string parameter
  +param=filename       Set stylesheet document parameter
  ?param=expression     Set stylesheet parameter using XPath
  !param=value          Set serialization parameter
C:\Users\radu_pisoi\Desktop\test-saxon-next-chain>java -Xmx60m -cp saxon_9_5/saxon9ee.jar net.sf.saxon.Transform -s:test_files/instance.xml -xsl:test_files/main
.xsl -o:test_files/res1.xml
Document URI: file:/C:/Users/radu_pisoi/Desktop/test-saxon-next-chain/test_files/res1.xml

With Saxon 9.6:

C:\Users\radu_pisoi\Desktop\test-saxon-next-chain>java -Xmx60m -cp saxon_9_6/saxon9ee.jar net.sf.saxon.Transform
No source file name
Saxon-EE 9.6.0.6J from Saxonica
Usage: see http://www.saxonica.com/html/documentation/using-xsl/commandline.html
Format: net.sf.saxon.Transform options params
Options available: -? -a -catalog -config -cr -dtd -expand -explain -ext -im -init -it -l -m -now -o -opt -or -outval -p -quit -r -repeat -s -sa -strip -t -T -t
hreads -TJ -TP -traceout -tree -u -val -versionmsg -warnings -x -xi -xmlversion -xsd -xsdversion -xsiloc -xsl -xsltversion -y
Use -XYZ:? for details of option XYZ
Params:
  param=value           Set stylesheet string parameter
  +param=filename       Set stylesheet document parameter
  ?param=expression     Set stylesheet parameter using XPath
  !param=value          Set serialization parameter
C:\Users\radu_pisoi\Desktop\test-saxon-next-chain>java -Xmx60m -cp saxon_9_6/saxon9ee.jar net.sf.saxon.Transform -s:test_files/instance.xml -xsl:test_files/main
.xsl -o:test_files/res1.xml
Document URI:

So, I get different results of the document-uri(/) function in Saxon 9.5 and 9.6. In 9.5 I'm getting the URI of the output document while in 9.6 I'm getting the empty string.

Maybe the behavior from Saxon 9.5 is expected by users that compute absolute paths depending the result of this function.

For instance, we have a user that tries to compute an URI relative to the document-uri of the root element:

<xsl:variable name="datei" select="replace(document-uri(/), '.xml$' ,'_META.xml')"/>
Actions #3

Updated by Michael Kay over 9 years ago

I don't know why we're getting different results under 9.5. But it doesn't seem correct to me that the second stylesheet should get a result for document-uri(/) that is not actually usable to get the relevant document using the doc() function. It's supposed to be an invariant that if document-uri($D) = $U, then doc($U) is $D. I can't see how that can be made to work here, since the document in question is transient, it exists only in memory on the pipeline between the two transformations. I think Saxon 9.6 is behaving correctly.

Maybe the behavior from Saxon 9.5 is expected by users that compute absolute paths depending the result of this function.

For instance, we have a user that tries to compute an URI relative to the document-uri of the root element:

It would surely be more appropriate to use base-uri() for that purpose rather than document-uri(). I don't think the spec of saxon:next-in-chain says what the base URI of the intermediate file is. It would be quite reasonable for it to have a base URI, though there's room for debate as to what the base URI should be.

Actions #4

Updated by Radu Pisoi over 9 years ago

Michael Kay wrote:

It would surely be more appropriate to use base-uri() for that purpose rather than document-uri(). I don't think the spec of saxon:next-in-chain says what the base URI of the intermediate file is. It would be quite reasonable for it to have a base URI, though there's room for debate as to what the base URI should be.

It's a bit tricky to find a solution for this problem because the temporary document could be considered both an input and an output document. It is an output document for the first transformation but also it is an input document for the second one.

In Saxon 9.5 the base URI property for the temporary document is set to the URI of the output document. So, for backward compatibility, maybe a good solution is to set it to the output URI.

Actions #5

Updated by Michael Kay almost 7 years ago

  • Status changed from New to Won't fix

Closing this as "won't fix". I don't think it would be correct for document-uri() to return a URI for the intermediate file, since doc() applied to that URI would not return the document.

Please register to edit this issue

Also available in: Atom PDF