X hits on this document

392 views

0 shares

1 downloads

0 comments

25 / 142

Document type definitions

If an element is not qualified with one of these symbols, then the element can appear once and only once. Consequently, in the example above, since pets is defined to contain the element pet, and the pet element is qualified with a plus sign, there must be at least one pet element within the pets element.

PCDATA

There is another value for element definitions you need to know, #PCDATA. This stands for parsed character data, and it is used to denote content that contains only text, text without markup.

Sequences

Finally, it is entirely possible that an element will contain multiple, sub elements. When strung together, this list of multiple elements is called a sequence, and they can be grouped together in the following ways:

  • comma (,) is used to denote the expected order of the elements in the XML file

  • parentheses (()) are used to group elements together

  • vertical bar (|) is used to denote a Boolean union relationship between the elements.

Putting it all together

Walking through the DTD for pets.xml we see that:

  • 1.

    The root element of the document should is pets.

  • 2.

    The root element, pets, contains at least one pet element.

  • 3.

    Each pet element can contain one and only one name, age, type, and color element, in that order.

  • 4.

    The elements name, age, type, and color are to contain plain text, no mark up.

Below is a DTD for the letter in a previous example.

<!ELEMENT

letter

<!ELEMENT

date

<!ELEMENT

addressee

<!ELEMENT

name

<!ELEMENT

address_one

<!ELEMENT

address_two

<!ELEMENT

greeting

<!ELEMENT

paragraph

<!ELEMENT

italics

<!ELEMENT

list

<!ELEMENT

item

<!ELEMENT closing

_ (date, addressee, greeting, (paragraph+ | list+)* (#PCDATA)> (name, address one, address two)> (#PCDATA)> (#PCDATA)> (#PCDATA)> (#PCDATA)> (#PCDATA | italics)*> (#PCDATA)> (item+)> (#PCDATA)> (#PCDATA)> _

This example is a bit more complicated. Walking through it we see that:

17

, closing)

Document info
Document views392
Page views398
Page last viewedSun Dec 04 15:30:17 UTC 2016
Pages142
Paragraphs3126
Words34660

Comments