Re: [xsl] question about generate-id()

Subject: Re: [xsl] question about generate-id()
From: Lars Huttar <lars_huttar@xxxxxxx>
Date: Thu, 05 Aug 2010 10:36:02 -0500
On 8/5/2010 1:49 AM, Dave Pawson wrote:
> On Wed, 04 Aug 2010 18:18:40 -0400
> "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> wrote:
>
>   
>> The uniqueness of identifiers is guaranteed only when generate-id() 
>> is used for every identifier.  This makes sense because generate-id() 
>> has no way of knowing which of your attributes are identifiers and 
>> which are not.
>>     
> Not even when the 'id' values are @id? That sounds wrong Ken. 
>
> 16.6.4
> There is no guarantee that a generated unique identifier will be
> distinct from any unique IDs specified in the source document.
>
> Yuk. IMHO that's a spec weakness. More constrained, surely
> it's not rocket science to implement.
>   

Even if the XSLT processor knew which of the output attributes were
identifiers and which were not, I think this guarantee would be
theoretically impossible to fulfill, because someone could always write
a stylesheet that

1) uses generate-id() to produce an id attribute node; and
2) copies the generated node as another id attribute.

Then no matter what the processor does, you end up with either a pair of
id's that are the same, or a copy that didn't obey copy semantics. Even
postponing determination of the generated id's will not help in this case.

That may be a silly example, but it does show that such a guarantee is
not possible to fulfill in all cases. And there are probably cases that
are less obvious, and which people will stumble across accidentally.

By "more constrained", did you mean that it may be possible to guarantee
uniqueness of generated id's if the guarantee were more constrained?

Lars

Current Thread