[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: generating ids across multiple source documents in xslt


multiple source xslt saxon
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@C...
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


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.