Sign In/My Account | View Cart  
advertisement


Listen Print Discuss

Identity Crisis
by Leigh Dodds | Pages: 1, 2

xml:id

Tim Bray proposed that a reserved attribute, in the XML namespace, be used to explicitly associate identifiers with elements. One of the benefits of using the reserved XML namespace is that it need not be declared, making it simple to add identifiers without additional changes to the instance. The obvious downside is that many DTDs will have to be updated to make these attributes valid for use on particular elements.

Example usage:


<foo>
<bar xml:id="label1">
<baz xml:id="label2">
</foo>

xmlid:xx

Offered as a variant of Bray's proposal, this option uses an explicit "identifier namespace". Any attribute associated with this namespace would be taken as an identifier. This adds the possibility of multiple identifiers per element. There hasn't been much backing for this proposal as the benefits of the additional flexibility aren't widely acknowledged.

Example usage:


<foo xmlns:xmlid="http://w3.org/xmlid">
  <bar xmlid:x="abc" />
  <baz xmlid:z="hij" />
</foo>

xml:idatt

This proposal from James Clark has received the most vocal support so far.

An alternative would be to have an attribute that declares the name of the attribute that is an ID attribute, say xml:idatt. To make this usable, xml:idatt would be inherited. In the typical case where all elements use the same attribute name for an ID, this means that a user has only to add something like xml:idatt="id" or xml:idatt="rdf:ID" to their root element and everything works. You would also need to allow xml:idatt="" to disable inheritance.

Example usage:


<foo xml:idatts="x">
  <bar x="abc"/>
  <baz x="hij" />
</foo>

Minimal Victories

Not everyone has been convinced that a generic solution is required, and some of them have been looking instead for a minimal victory. David Carlisle proposed revising how XPointer interprets a fragment identifier, so that as well as using the id function, it checks for attributes called "id". This results in a rather scary XPath expression:

id('Chapter12')|/*[not(id('foo'))]/descendant-or-self::*[@*[local-name()=3D= 'id' and .3D 'Chapter12']][1]

Elliotte Harold was also of the opinion that the architectural hole could be plugged by a change limited to XPointer alone.

...I issue a new request for a standard xml:target attribute. This would provide a unique name for XPointers to link to. It would have no necessary type. It would have no affect on validity. The documents in which it appears may or may not have DTDs, may or may not be valid, and may or may not declare this attribute with any particular type. Whether such a document was valid would be determined exactly according to the rules of XML 1.0.

A good deal of discussion is likely to be needed before consensus forms. There are some issues related to all proposals presented so far (the Deviant is attempting to maintain a list of these separately), and there are several options for how things might proceed.

Moving Forward

If consensus settles on an XPointer-only fix, then there is likely to be pressure applied by the community to have the specification returned to Working Draft status to resolve this issue. It's disappointing that a specification can get this close to becoming a Recommendation with such a big loophole. Something has failed somewhere. In fact it may turn out that this problem has already been considered and rejected. Without disclosure of Working Group discussion it's difficult to surmise anything.

If the consensus is that a more general solution is required, then the appropriate way forward seems to be for a Note to be submitted to the W3C documenting the proposal with the aim of it becoming a separate Recommendation. Tim Bray has suggested that this would be simpler than re-opening the XML specification.

Michael Champion observed that such a specification might actually be created as a community activity, perhaps with it entering a standardization process after implementation experience.

Something like RDDL is *exactly* what I would like to see here. It's just a nice suggestion for a way forward that tools developers can implement rather than re-inventing the id-ness wheel or leaving it to the application writers. Concrete experience with it in the field may motivate the W3C (or ISO, or whoever comes along and applies the lessons of history to XML 1.0) to put it in a "real" standard someday.

While this discussion may seem slightly esoteric -- it certainly doesn't significantly derail the web service or XML-EDI approaches -- it demonstrates that gaps in the web architecture are still appearing, gaps which clearly point to a need for a group like the TAG, the elections for which end on 28 November.

Those with a keen eye will have also realized that separating out the responsibility for the declaration of identifiers could further attenuate the role of DTDs, taking us another step closer to a more layered architecture.


Comment on this articleHow would you fix the ID attribute problem? Share your views in our forum.
(* You must be a
member of XML.com to use this feature.)
Comment on this Article


Titles Only Titles Only Newest First
  • Here's an idea....
    2002-04-27 16:04:49 James Cerra [Reply]

    Here's an idea....


    According to the spec (1) XML namespaces can (and do) associate attribute names with URI references.


    Well, I noticed that the URI doesn't have to be a URL to an external document (2). This is different from pointing to a relative namespace, which is depreciated (3); in this case I'm thinking about pointing into the document itself. This would be accomplished using an absolute XPointer child sequence, as in:


    <?xml version="1.0"?>
    <root xmlns:id1="/1/1/3"
    xmlns:id2="/1/2/1">
    <child1>
    <child11>...</child11>
    <child12>...</child12>
    <child13 id1:uri="/1/1/3">...</child13>
    </child1>
    <child2>
    <child21 id2:uri="/1/2/1">...</child21>
    <child22>...</child22>
    </child2>
    </root>


    I really don't think this is a good way of describing ids. However, it's just a thought that may spur better ideas. :)


    ---
    Jimmy Cerra
    jc2astro@hotmail.com
    "If the path is set in stone, use a sledgehammer."


    ---
    Disclaimer: I'm not saying it's a good idea! I'm just asking what you think. :)


    ---
    notes:


    ---
    1) From the abstract of (http://www.w3.org/TR/REC-xml-names/): "XML namespaces provide a simple method for qualifying element and attribute names used in Extensible Markup Language documents by associating them with namespaces identified by URI references."


    ---
    2) The namespace's URI doesn't even have to physically point to somewhere at all (although it should). See this: http://www.rpbourret.com/xml/NamespacesFAQ.htm#q12_4


    ---
    3) See: http://www.rpbourret.com/xml/NamespacesFAQ.htm#q12_5

  • Can XPointer use an id declared in Schema?
    2001-11-09 05:43:22 Steven Tolkin [Reply]

    Most of this dicsussion states that the id
    attribute needs to be declared in a DTD.
    What is the instance document has an
    XML Schema, which declares an id attribute?
    Will this work?
    Is the fact that XPointer spec discusses DTDs
    merely a side effect caused by it being
    written before Schema became a Recommendation?


    steve.tolkin@fmr.com 2001-11-09