This section describes the built-in datatype 'ID' designed to primarily support the id attribute to identify a specific XML element. 'ID' values must be 'NCName' values and must be unique in a single XML document.
The second datatype derived from "NCName" is "ID, which is designed to primarily support values
used in the id attribute to identify a specific XML element.
"ID" is a datatype derived from "NCName" datatype with these rules:
A "ID" value must be "NCName" value.
"ID" values must be unique in an single XML document.
"ID" values are allowed to use as both element contents and attribute values.
Here is a sample XSD document that defines 2 sub element <IDElement> and <IDAttribute>
to use "ID" values as element contents and as element attributes:
Here is the output of the JDK 1.7 tool XsdSchemaValidator.java on this test.
It is reporing 4 groups of errors for those 4 invalid elements.
c:\Progra~1\Java\jdk1.7.0_07\bin\java.exe XsdSchemaValidator
id_datatype_test.xsd id_datatype_test.xml
Error:
Line number: 13
Column number: 36
Message: cvc-id.2: There are multiple occurrences of ID value
'site-logo'.
Error:
Line number: 13
Column number: 36
Message: cvc-type.3.1.3: The value 'site-logo ' of element
'ID_Element' is not valid.
Error:
Line number: 14
Column number: 48
Message: cvc-datatype-valid.1.2.1: '2835c0d60046c109' is not a
valid value for 'NCName'.
Error:
Line number: 14
Column number: 48
Message: cvc-type.3.1.3: The value ' 2835c0d60046c109 ' of
element 'ID_Element' is not valid.
Error:
Line number: 15
Column number: 40
Message: cvc-datatype-valid.1.2.1: 'std:out' is not a valid value
for 'NCName'.
Error:
Line number: 15
Column number: 40
Message: cvc-type.3.1.3: The value ' std:out ' of element
'ID_Element' is not valid.
Error:
Line number: 23
Column number: 32
Message: cvc-id.2: There are multiple occurrences of ID value
'stdin'.
Error:
Line number: 23
Column number: 32
Message: cvc-attribute.3: The value ' stdin ' of attribute
'ID' on element 'ID_Attribute' is not valid with respect to its
type, 'ID'.
Failed with errors: 8