[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [xml-dev] Re: determining ID-ness in XML
- From: David Carlisle <email@example.com>
- To: firstname.lastname@example.org
- Date: Thu, 01 Nov 2001 09:32:52 +0000 (GMT)
> > / descendants-or-self::*[attval::*[local-name() = 'id'] = 'foo']
> > An inelegant solution to be sure. (Though this is basically
> > what I always do anyway when I need to identify IDs, since
> > in practice it's more reliable than anything else.)
> This was looked at. And existing DTDs with id attributes not of type
> ID seems to exist. This totally break them, and make pointing unreliable
> because a lot of tools expects #foo to point to the ID of name foo, and
> you could actually end up pointing to a different part of the document
> against the author(s) intent. Compatibility with the XPath id() function
> was considered really important too.
A version of the definition that would address both those concerns is:
id('foo')|/*[not(id('foo'))]/descendant-or-self::*[@*[local-name()='id' and . = 'foo']]
ie, use (the first) element node with ID 'foo' if one exists otherwise use the
first element node with an attribute in any (or no) namespace with local
name 'id' and value 'foo'.
This does have some advantages in that like the Xpath id() function it
doesn't impose any requirememts on the parsers to check any new kind of
uniqueness constraint, and so doesn't require changes to current systems
(except systems implementing fragment id's pointing to xml files, and
these are rather thin on the ground, currently).
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.