Why cant xml:id be numeric only ?

View: New views
4 Messages — Rating Filter:   Alert me  

Why cant xml:id be numeric only ?

by DALDEI :: Rate this Message:

| View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

First off I know asking "Why" for anything standards related is silly.

 

But given that, could anyone give me a rationale or history for restricting xml:id (or the ID type from DTD) to be NCName which then has to start with non-numeric ?

It seems such an *obvious* (to me!) concept that an ID could be fully numeric like   xml:id="12345".

Why force it to start with a letter  like  xml:id="a123" (or a DTD or schema ID value'd attribute like  id="12345" )

I know I can fairly easily add such a letter, then hack all the queries to prepend the letter ... but I'm very curious why the constraint ?  I would guess a great deal of ID's 'in the wild' are purely numeric.

 

Use Case: Why I'm asking is that I have a large number of documents which are effectively dumps from a database.

Each element has a 'natural ID' which is the integer primary key from the database.

I'm trying to optimize XQuery & xslt to use the built-in indexing in common engines which supports "ID" values via  fn:id() and have discovered to my surprise I simply cant use numeric values for an ID.  Quite curious.

 

 

-David

 

 

 

 

----------------------------------------

David A. Lee

dlee@...

http://www.xmlsh.org

 


Re: Why cant xml:id be numeric only ?

by Michael Kay :: Rate this Message:

| View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
On 29/04/2011 15:22, David Lee wrote:

First off I know asking "Why" for anything standards related is silly.

 

But given that, could anyone give me a rationale or history for restricting xml:id (or the ID type from DTD) to be NCName which then has to start with non-numeric ?



I seem to recall asking this once, and being told that the history lay in the SGML rules for abbreviated syntax. Something like allowing <e id="xyz"/> to be abbreviated as <e xyz>. Not that this in itself would make a numeric identifier ambiguous, but it would account for requiring an ID value to have the same syntax as an attribute name.

I guess another justification is that it prevents any debate about whether xml:id="01234" is a duplicate of xml:id="1234".

Michael Kay
Saxonica

RE: Why cant xml:id be numeric only ?

by DALDEI :: Rate this Message:

| View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Thanks,  I suspected something from the distant SGML land as it seems entrenched in the DTD history ..

 

But obviously any sane person would assume

                xml:id="D000001"   == xml:id="D1"

 

:) 1/2

 

 

 

----------------------------------------

David A. Lee

dlee@...

http://www.xmlsh.org

 

From: Michael Kay [mailto:mike@...]
Sent: Friday, April 29, 2011 10:42 AM
To: xml-dev@...
Subject: Re: [xml-dev] Why cant xml:id be numeric only ?

 

On 29/04/2011 15:22, David Lee wrote:

First off I know asking "Why" for anything standards related is silly.

 

But given that, could anyone give me a rationale or history for restricting xml:id (or the ID type from DTD) to be NCName which then has to start with non-numeric ?

 


I seem to recall asking this once, and being told that the history lay in the SGML rules for abbreviated syntax. Something like allowing <e id="xyz"/> to be abbreviated as <e xyz>. Not that this in itself would make a numeric identifier ambiguous, but it would account for requiring an ID value to have the same syntax as an attribute name.

I guess another justification is that it prevents any debate about whether xml:id="01234" is a duplicate of xml:id="1234".

Michael Kay
Saxonica


Re: Why cant xml:id be numeric only ?

by John Cowan-3 :: Rate this Message:

| View Threaded | Show Only this Message

Michael Kay scripsit:

> I seem to recall asking this once, and being told that the history
> lay in the SGML rules for abbreviated syntax. Something like allowing
> <e id="xyz"/> to be abbreviated as <e xyz>. Not that this in itself
> would make a numeric identifier ambiguous, but it would account for
> requiring an ID value to have the same syntax as an attribute name.

For the same reason, it's invalid SGML to have a DTD like this:

<!ELEMENT foo EMPTY>
<!ATTLIST foo att1 (val1|val2)
          foo att2 (val2|val3)>

because <foo val2> would be ambiguous as a short form of either <foo
att1="val2"> or <foo att2="val2">.  This restriction appears in the
final paragraph of Section 3.3.1 of the XML Recommendation:

    For interoperability, the same Nmtoken SHOULD NOT occur more than
    once in the enumerated attribute types of a single element type.

--
John Cowan    http://ccil.org/~cowan    cowan@...
[T]here is a Darwinian explanation for the refusal to accept Darwin.
Given the very pessimistic conclusions about moral purpose to which his
theory drives us, and given the importance of a sense of moral purpose
in helping us cope with life, a refusal to believe Darwin's theory may
have important survival value. --Ian Johnston

_______________________________________________________________________

XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@...
subscribe: xml-dev-subscribe@...
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php