xsl-list
[Top] [All Lists]

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

2010-08-05 04:11:21
On Thu, August 5, 2010 7:49 am, Dave Pawson wrote:
On Wed, 04 Aug 2010 18:18:40 -0400
"G. Ken Holman" <gkholman(_at_)CraneSoftwrights(_dot_)com> 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.

Possibly not everybody uses @id to mean an ID, plus there's plenty of
other attributes, such as @name, that may or may not be IDs.  The only
attribute that is guaranteed to be an ID is @xml:id, and that postdates
XSLT 1.0 by about six years.

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.

You could do it yourself with keys and a bit of checking, but in the
general case, not everybody will need to search a possibly large source
document in the off-chance that a duplicate ID will be generated (though
if you keep using the same XSLT processor over slightly modified versions
of the same source document, you do stand a good chance of creating
duplicates.)

In this brave new world of streaming XSLT, you might not see the existing
ID value until after you've generated what would be a duplicate ID.

The earlier idea of adding a timestamp to the generated ID, or even a
known prefix if you do things in fixed phases, would be less overhead than
avoiding existing IDs.  I've also implemented a uuid() extension function
for a client to guarantee that generated IDs are unique.

Regards,


Tony Graham                         
Tony(_dot_)Graham(_at_)MenteithConsulting(_dot_)com
Director                                  W3C XSL FO SG Invited Expert
Menteith Consulting Ltd                               XML Guild member
XML, XSL and XSLT consulting, programming and training
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
Registered in Ireland - No. 428599   http://www.menteithconsulting.com
  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
xmlroff XSL Formatter                               http://xmlroff.org
xslide Emacs mode                  http://www.menteith.com/wiki/xslide
Unicode: A Primer                               urn:isbn:0-7645-4625-2


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--