xsl-list
[Top] [All Lists]

Re: Identity of Documents Puzzle

2002-12-06 18:53:58
At 2002-12-06 18:08 -0600, W. Eliot Kimber wrote:
My question: is there any way, other than passing in the filename of the top-level file as a parameter to the style sheet, to ensure that the node for the document as created by the initial style sheet processing is the same as one for a call to document() for the same file (it may or may not be the same filename depending on the relative locations of the files involved)? I can't think of one, but there are many subtleties of XSLT that I have yet to master.

I immediately thought of using the generated identifier of the root node, because 12.1 states "Two documents are treated as the same document if they are identified by the same URI."

This empirically doesn't apply to the URI of the source file and the URI supplied to the document() function, though I had anticipated it would be.

The evidence is that neither XT nor Saxon bear this out in the test below where I use the same URI on the command line as in the document() function, so I think you are out of luck for something automatic and that you will have to pass the filename as an argument.

When I've needed to guarantee unique identifiers from multiple documents, I just change every identifier to its generated identifier and the resulting document is self-referentially ID/IDREF okay.

Can someone from the WG comment on the quote above and the test below?

.................... Ken

X:\samp>type genid2.xsl
<?xml version="1.0"?><!--genid2.xsl-->
<!--XSLT 1.0 - http://www.CraneSoftwrights.com/training -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

<xsl:template match="/">
Source:  <xsl:value-of select="generate-id(.)"/>
SSheet:  <xsl:value-of select="generate-id(document(''))"/>
genid2:  <xsl:value-of select="generate-id(document('genid2.xsl'))"/>
</xsl:template>

</xsl:stylesheet>

X:\samp>xt genid2.xsl genid2.xsl
<?xml version="1.0" encoding="utf-8"?>

Source:  N0
SSheet:  N1_0
genid2:  N1_0
X:\samp>saxon genid2.xsl genid2.xsl
<?xml version="1.0" encoding="utf-8"?>
Source:  d0
SSheet:  d1
genid2:  d1
X:\samp>


--
Upcoming hands-on in-depth XSLT/XPath and/or XSL-FO:
-                             North America:  Feb 3 - Feb 7,2003

G. Ken Holman               mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.        http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0  +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                     Definitive XSLT and XPath
ISBN 0-13-140374-5                             Definitive XSL-FO
ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
ISBN 1-894049-10-1             Practical Formatting Using XSL-FO
Next conference training:                    2002-12-08,03-03,06


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>