What is the typical maximum length of values of the XML/XSD ID/IDREF types?

1.8k Views Asked by At

The W3C XSD 1.0 Part 2: Datatypes specification refers to the W3C XML 1.0 specification for the definition of the ID and IDREF types, but none of these documents defines any constraints on the length of values of these types.

However, it seems that some XML editors implement length limitations for these types.

Also, some Web browsers seem to implement length limitations, e.g. on the "id" attribute of the HTML Hx elements (which is defined as XML ID type in both HTML 4 and XHTML 1.1).

  1. Are there any constraints on the length of the ID/IDREF types defined by a W3C specification or some other specification ?

  2. What are typical length constraints implemented by XML editors ?

  3. What are typical length constraints implemented by Web browsers (for HTML) ?

1

There are 1 best solutions below

0
On

Actually, it's pretty clear that every XML parser now in existence has a length limitation on values of type ID and IDREF, because every XML parser now in existence runs on a machine with a finite amount of storage (and usually the parser has a much smaller limit on the amount of storage it is prepared to use in parsing documents).

The only pattern I'm aware of (based on my limited experience) is that it's not unusual for the effective limit to be given not by a predefined quantity but by the amount of memory available at the crucial instant at run time.

I believe some users simply decree that they will not use identifiers longer than 32 characters; I suspect most XML editors will accept identifiers whose length is one or two orders of magnitude greater.

And to answer your first question: there are no constraints on the length of ID/IDREF (or anything else in the XML spec) defined in any W3C spec that I am aware of. All implementations will necessarily have limits, but there is no spec that I know of that sets a minimum level for those limits, and I suspect that any attempt to define a set level for those limits would be shot down immediately in a barrage of scorn. (XSD 1.1 does set minimum limits for the support of some infinite datatypes, but says nothing about minimum length limits for ID and IDREF; strictly speaking the value and lexical spaces of those types are always finite, so perhaps the focus of section 5.4 on infinite datatypes made them seem out of scope.)