DTD Basics   «Prev 

How do you specify information in a XML Element Declaration?

How do you specify information in a XML Element Declaration? In an XML element declaration, you can specify the name of the element and the content model that defines the structure of the element. The content model specifies the types and order of child elements that are allowed within the element, as well as any text content or mixed content that may be allowed.
Here is an example of an XML element declaration that defines an element named "person" with child elements for "name", "age", and "address":
<!ELEMENT person (name, age, address) >
<!ELEMENT name (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT address (street, city, state, zip)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT state (#PCDATA)>
<!ELEMENT zip (#PCDATA)>

In this example, the first line defines the "person" element as having child elements for "name", "age", and "address". The second line defines the "name" element as containing only character data (i.e. text content), using the "#PCDATA" keyword. The third line does the same for the "age" element. The fourth line defines the "address" element as having child elements for "street", "city", "state", and "zip". Each of these child elements is defined on separate lines as containing only character data. Note that there are many other types of content models that can be used in an XML element declaration, including element repetitions, choices, and sequences. The choice of content model depends on the specific needs and requirements of the XML document being defined.