[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] generate-id() explanation


Subject: Re: [xsl] generate-id() explanation
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 24 May 2010 17:49:49 +0100

On 24/05/2010 17:29, a kusa wrote:
Hi

I would like to clarify if my understanding of generate-id() is correct.

A generate-id() when used within an XML document on multiple nodes,
generates unique id values for each of the nodes.


Is this correct?

yes or even within multiple documents (in the same transform) generate-id() is guaranteed to give a different string for each node.

The reason I am asking is because I am generating ids for a nested level in an XML document using generate-id() and the requirement is to generate a unique id for each of the list level elements in one XML document.

Can the experts please clarify this?


Note generate-id(0 is an easy way of generating ids but if it is for a public facing document then beware that it makes URI refereces that are inherently opaque and unstable rather than having


http://example.com/foo.html#section3.4

you get


http://example.com/foo.html#njagsd3672


and should you have course to generate that document again 9possibly without even changing the source) all the URI references change and might become


http://example.com/foo.html#npiu6ogljgk




compare

http://www.w3.org/TR/2001/REC-MathML2-20010221/chapter3.html#N4116

and the URI ref to the 2nd edition which is

http://www.w3.org/TR/MathML2/chapter3.html#id.3.1.2

the default xmlspec stylesheets use a fragment identifier based on an id attribute in the source if there is one, and use generate-id() if not
but for mml2 2nd edition I changed thigs round so that if there is no id it generated an id using xsl:number, which is far more stable between drafts as the text was edited.


David



________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________



Current Thread
Keywords
xml