XML - Declaration (validation|constraint)

> Markup Language (ML) > Extensible Markup Language (XML)

1 - About

The element structure of an XML document may, for validation purposes, be constrained using:



3 - Declaration Type

3.1 - Element type

3.1.1 - Definition

An element type declaration constrains the element's content.

Element type declarations often constrain which element types can appear as children of the element.

An XML processor may issue a warning when a declaration mentions an element type for which no declaration is provided, but this is not an error.

3.1.2 - Syntax

<!ELEMENT Name contentspec>


  • name gives the element type
  • contentspec is one of the following specification: - empty

empty element declaration

Advertising - any
<!ELEMENT container ANY> - mixed

mixed content declarations:

<!ELEMENT p (#PCDATA|a|ul|b|i|em)*>
<!ELEMENT p (#PCDATA | %font; | %phrase; | %special; | %form;)* >

The keyword #PCDATA derives historically from the term “parsed character data.” - children

element content model

<!ELEMENT spec (front, body, back?)>
<!ELEMENT div1 (head, (p | list | note)*, div2*)>
<!ELEMENT dictionary-body (%div.mix; | %dict.mix;)*>

where the cardinality operator:

  • one or more (+),
  • zero or more (*),
  • or zero or one times (?).
  • (default|absence): once

3.2 - Attribute-list

Attribute-list declarations specify:

  • the name,
  • data type,
  • and default value (if any)

of each attribute associated with a given element type.