XML - (Markup) Declaration (validation|constraint)

Card Puncher Data Processing


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

declarations defined in the doctype:

These declarations may be contained in whole or in part within parameter entities

Declaration Type

Element type


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.


<!ELEMENT Name contentspec>


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

empty element declaration

<!ELEMENT container ANY>

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 (relationship)

element content model

Declaration Relationship (Cardinality)
<!ELEMENT master (child)> One and only once
<!ELEMENT master (child+)> One or more
<!ELEMENT master (child*)> Zero or more
<!ELEMENT master (child?)> Zero or one


<!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


Attribute-list declarations specify:

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

of each attribute associated with a given element type.

Example with doctype:

<?xml version="1.0" encoding="UTF-8"?>
        <!ELEMENT TABLE (ROW)*>
        <!ELEMENT ROW (#PCDATA)>
    <ROW COL1="25874" COL2="000005" />
    <ROW COL1="26084" COL2="000006" />

Discover More
Card Puncher Data Processing
XML - (Structured) Document

Documents are built from node (elements and text node between node element). These elements form a tree using the DOM. Each XML documents begin with an XML declaration which specifies the version of...
Card Puncher Data Processing
XML - (Structure|Representation)

Each XML document has both: a and a structure. XML provides a mechanism, the document type declaration: to define constraints on the logical structure and to support the use of predefined...
Card Puncher Data Processing
XML - Attribute

Attribute in XML represents the (tree) attributes of an HTML element (node in the tree) Ie they are used to associate name-value pairs with elements and are defined in a start tag of an empty tag. The...
Card Puncher Data Processing
XML - Document Type (Definition|Declaration) (DTD)

Document Type Definition (DTD) is a grammar (language) that defines the schema (ie data structure) of an XML document. It defines constraints on the logical structure supports the use of predefined...
Card Puncher Data Processing
XML - Element

Each XML document contains one or more elements, the boundaries of which are either delimited by: start-tags and end-tags, or, for empty elements, by an empty-element tag. The element structure...
Card Puncher Data Processing
XML - Entity (Physical Storage)

An XML document may consist of one or many physical units (storage) that are called entities. Entities may be either parsed or unparsed. A parsed entity contains text, a sequence of characters,...
Card Puncher Data Processing
XML - Markup

The function of the markup in an XML document is to describe its structure: storage (physical) and logical structure (and to associate attribute name-value pairs with its logical structures). Markup...
Card Puncher Data Processing
XML - doctype

doctype is a DTD schema definition. It MUST appear before the first element in the document. The HTML doctype: Example of attribute declarations ...

Share this page:
Follow us:
Task Runner