Oracle8i Application Developer's Guide - XML Release 3 (8.1.7) Part Number A86030-01 |
Library | Service | Contents | Index

An XML Primer, 7 of 9

## Extensibility and Document Type Definitions (DTD)

Another key advantage of XML over HTML is that it leaves the specification of the tags and how they can be used to the user. You construct an XML document by creating your own tags to represent the meaning and structure of your data.

Tags may be defined by using them in an XML document or they may be formally defined in a Document Type Definition (DTD). As your data or application requirements change, you can change or add tags to reflect new data contexts or extend existing ones.

The following is a simple DTD for the previous XML example:

      <!ELEMENT EMPLIST (EMP)*>
      <!ELEMENT EMP (EMPNO, ENAME, JOB, SAL)>
      <!ELEMENT EMPNO (#PCDATA)>
      <!ELEMENT ENAME (#PCDATA)>
      <!ELEMENT JOB (#PCDATA)>
      <!ELEMENT SAL (#PCDATA)>
      ]>

    Note:

    The DOCTYPE declaration is only used when the DTD is embedded in XML code.

### Well-Formed and Valid XML Documents

#### Well-Formed XML Documents

An XML document that conforms to the structural and notational rules of XML is considered well-formed. A well-formed XML document does not have to contain or reference a DTD, but rather can implicitly define its data elements and their relationships. Well-formed XML documents must follow these rules:

- Document must start with the XML declaration, <?xml version="1.0">

- All elements must be contained within one root element

- All elements must be nested in a tree structure without overlapping

- All non-empty elements must have start and end tags

#### Valid XML Documents

Well-formed XML documents that also conform to a DTD are considered valid. When an XML document containing or referencing a DTD is parsed, the parsing application can verify that the XML conforms to the DTD and is therefore valid, which allows the parsing application to process it with the assurance that all data elements and their content follow rules defined in the DTD.

| Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
Library | Service | Contents | Index