In a Document Type Definition (DTD) an attributes type can be set to be IDREFS.
For a value to be a valid IDREFS the following must be true:-
[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
[5] Name ::= NameStartChar (NameChar)*
[6] Names ::= Name (#x20 Name)*
Declaring an IDREF Attribute in a DTD |
Copy Code
|
---|---|
<!ELEMENT artist EMPTY> <!ATTLIST artist name CDATA #REQUIRED> <!ATTLIST artist artistID ID #REQUIRED> <!ELEMENT album EMPTY> <!ATTLIST album name CDATA #REQUIRED> <!ATTLIST album albumArtistID IDREF #IMPLIED> <!ATTLIST album contributingArtistIDs IDREFS #IMPLIED> |
Sample XML |
Copy Code
|
---|---|
<artist name="Nick Cave" artistID="NC"/> <artist name="Kylie Minogue" artistID="KM"/> <artist name="PJ Harvey" artistID="PJH"/> <artist name="Shane MacGowan" artistID="SM"/> <album name="Murder Ballads" albumArtistID="NC" contributingArtistIDs="KM PJH SM"/> |
When an XML document is read in conjunction with a DTD the IDREFS value has the standard attribute whitespace normalization rules are applied plus an additional level of normalization.
3.3.3 Attribute-Value Normalization
Before the value of an attribute is passed to the application or checked for validity, the XML processor MUST normalize the attribute value by applying the algorithm below, or by using some other method such that the value passed to the application is the same as that produced by the algorithm.
3.3.3 Attribute-Value Normalization
If the attribute type is not CDATA, then the XML processor MUST further process the normalized attribute value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters by a single space (#x20) character.