OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] generating ids across multiple source documents in xslt

[ Lists Home | Date Index | Thread Index ]

At 2004-04-13 16:41 -0400, Engel, Phillip wrote:
>I am looking for some help on the correct interpretation of the
>generate-id() function with multiple source documents.

XSLT and XPath questions would be better posted to the following list:

   http://www.mulberrytech.com/xsl/xsl-list

There are a number of subscribers who would enthusiastically respond to 
such questions.

There is also an *excellent* FAQ at:

   http://www.dpawson.co.uk

>I am writing an xslt style sheet that combines multiple input documents into
>one output document.  The original source document has references to other
>documents which in turn may have more references to more documents.
>Basically, it is a chain of href attributes.  As part of the process I use
>the generate-id() function on the root of each input document and keep it on
>a stack so I can keep track of which documents have been processed.  So in
>the code I have something like:
>
><value-of select="generate-id(document($nextDocument))"/>
>
>I've run this style sheet with saxon and msxml4 and have had no problems.
>However, when I run this using dot net (xsltransform.transform), I've
>discovered that this statement generates the same id for the root nodes of
>all input documents. So if I have:
>
><value-of select="generate-id(document('x.xml'))"/>
><value-of select="generate-id(document('y.xml'))"/>
>
>Both of these statements generate the same id using dot net, but different
>ids using saxon and msxml4.
>
>The xslt spec says that the generate-id() fucntion should generate a unique
>id for every node.  To me, since the root node of one document is a
>different node than the root of another document, I should get different
>ids.

Yes, you should get a different identifier value for every root node.

>It should not matter that the nodes are in difference source
>documents.

Because they are in different source documents, their root nodes should 
have different generated identifier values.

>Is this a correct interpretation of the spec?

Your supposition and Saxon and msxml4 are correct ... if your evidence 
rings true then dot net is not functioning according to the specification.

>I appreciate any thoughts.

First, I'm not sure why you are trying to keep track of the document root 
nodes ... if you access a document more than once the processor will have 
(should have) already cached it.  Also, two accesses to the generated 
identifier in a single run of a stylesheet are required to return the same 
value, so there is no harm looking at the same node twice.  Why go through 
the effort of maintaining a stack of visited documents?

When I teach aggregation using XSLT all of the ID/IDREF problems are solved 
by constructing the result tree nodes along the lines of:

      id="{generate-id(.)}"
  and
      idref="{generate-id(id(@idref))}"

This is important when aggregating hyperlinks within several documents 
being aggregated into a single XSL-FO result and having the links work in 
the result.

I hope this helps.

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

--
Public courses: Spring 2004 world tour of hands-on XSL instruction
Each week:   Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO
Hong Kong May 17-21; Bremen Germany May 24-28; Helsinki June 14-18

World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/x/bc





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS