Declaring Elements

As mentioned earlier, you can define the elements and the order in which they should occur. You can also determine how many times an element can occur. The element declaration for a DTD takes the following form:

<!ELEMENT name content_model>

Here the name argument is the name of the element and the content model can be one of the following:

  • EMPTY

  • ANY

  • An element content model

  • Character data

If the content is EMPTY, the element cannot have any data or subelements. This is often used to refer to external files such as graphics, and so on.

If the content is ANY, the element can contain any element that is declared in the DTD, or any type of text data or CDATA section. In our case, the forCDATA element contains the CDATA section. ...

Get Java™ APIs for XML Kick Start now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.