Try OpenEdge Now
skip to main content
Working with XML
Reading and Writing XML with the Document Object Model (DOM) : XML terminology : XML document structure : DTDs and XML Schema documents
 
DTDs and XML Schema documents
DTDs and XML Schema documents are rules that define the elements that can exist in a particular document or group of documents, and the relationships among the various elements. A DTD or XML Schema can be part of the content of an XML document or can be separate from it and referred to by the XML documents. Best practice calls for the DTDs and XML Schema documents to be separate from the XML content for resuse and maintainability. Here is an example of a DTD:
<?xml encoding="US-ASCII"?>
<!-- DTD for a an XML document that stores Customer names and numbers-->
<!ELEMENT customer(name, cust-num)>
<!ELEMENT name(#PCDATA)>
<!ELEMENT cust-num(#PCDATA)>
Here is an example of an XML Schema:
<?xml version="1.0"?>
<!-- XML Schema document for a an XML document that stores Customer names and numbers-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="">
  <xsd:element name="customer" minOccurs="0" maxOccurs="unbounded">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="CustNum" type="xsd:int"/>
        <xsd:element name="Name" type="xsd:string"/
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>