Re: Is " ID_234" a valid content for attribute of type xsd:ID?

Hi Noga,

> According to the spec ( http://www.w3.org/TR/xmlschema-2/#ID) ID
> value should be a valid NCName (
> http://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-NCName)
>
> Does it include values that start with space, such as "   ID_234"?

It doesn't include *values* that start with a space, but in an XML
element or attribute of that type, you can include spaces. For
example, the following id attribute holds a legal ID value:

  <foo id="    ID_234" />

The string value in an XML document goes through whitespace
normalization before its assessed to see if it's a valid value. For ID
values, whitespace normalization involves stripping away all the
leading and trailing whitespace (and substituting any internal runs of
whitespace with a single space, though if you have any internal runs
of whitespace then you can't have a legal value).

So the string value of the id attribute ("   ID_234") gets whitespace
normalized to "ID_234", which is a legal NCName. Note that this means
that the following are equivalent as far as an XML Schema processor is
concerned:

  <foo id="ID_234" />
  <foo id="   ID_234" />
  <foo id="   ID_234   " />

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Tuesday, 29 July 2003 06:18:41 UTC