DTD ENTITY

DTD > Data Types > DTD ENTITY

In a Document Type Definition (DTD) an attributes type can be set to be ENTITY.

For a value to be a valid ENTITY the following must be true:-

  • It must conform to the EBNF for "Name". In simple terms this means a "Name" has to start with a letter or ':' or '_'. The rest of the characters must be numbers, letters ':', '_', '-', or '.' it can not contain any spaces.
  • The value of the ENTITY attribute also has to match an ENTITY that has been declared elsewhere within the DTD.
[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)*
Declaring a ENTITY Attribute in a DTD Copy Code
<!ELEMENT MyElement EMPTY>
<!ATTLIST MyElement myEntityTest ENTITY #REQUIRED>
<!ENTITY myEntityA "Some Entity Value A">
<!ENTITY myEntityB "Some Entity Value B">
Sample XML Copy Code
<MyElement myEntityTest="myEntityA"/>

Whitespace

When an XML document is read in conjunction with a DTD an ENTITY 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.

  1. All line breaks MUST have been normalized on input to #xA as described in 2.11 End-of-Line Handling, so the rest of this algorithm operates on text normalized in this way.
  2. Begin with a normalized value consisting of the empty string.
  3. For each character, entity reference, or character reference in the unnormalized attribute value, beginning with the first and continuing to the last, do the following:
    • For a character reference, append the referenced character to the normalized value.
    • For an entity reference, recursively apply step 3 of this algorithm to the replacement text of the entity.
    • For a white space character (#x20, #xD, #xA, #x9), append a space character (#x20) to the normalized value.
    • For another character, append the character to the normalized value.

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.

 

See Also

Try Liquid XML Free and see how we can help you today Free Trial