Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Figures

Figure 1 DTD Type System

Type
Description
CDATA
Arbitrary character data
ID
A name that is unique within the document
IDREF
A reference to an ID value in the document
IDREFS
A space-delimited list of IDREF values
ENTITY
The name of an unparsed entity declared in the DTD
ENTITIES
A space-delimited list of ENTITY values
NMTOKEN
A valid XML name
NMTOKENS
A space-delimited list of NMTOKEN values
Figure 3 Complex Type Compositors

Compositor
DTD Equivalent
Definition
xsd:sequence
Comma-separated group
An ordered sequence of contained items
xsd:choice
Pipe-separated group
A choice of the contained items
xsd:all
None
All of the contained items in any order
Figure 4 Referencing Global Elements
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:tns="http://example.org/employee/"
  targetNamespace="http://example.org/employee/">
  <xsd:element name="employee">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="tns:name"/>
        <xsd:element ref="tns:hiredate"/>
        <xsd:element ref="tns:salary"/>
      </xsd:sequence> 
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="name"/>
  <xsd:element name="hiredate"/>
  <xsd:element name="salary"/>
</xsd:schema>
Figure 5 Avoiding Namespace Prefixes
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns="http://example.org/employee/"
  targetNamespace="http://example.org/employee/">
  <xsd:element name="employee">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="name"/>
        <xsd:element ref="hiredate"/>
        <xsd:element ref="salary"/>
      </xsd:sequence> 
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="name"/>
  <xsd:element name="hiredate"/>
  <xsd:element name="salary"/>
</xsd:schema>
Figure 6 Local Element Declarations
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://example.org/employee/">
  <!-- global element declarations -->
  <xsd:element name="employee">
    <xsd:complexType>
      <xsd:sequence>
        <!-- local element declarations -->
        <xsd:element name="name"/>
        <xsd:element name="hiredate"/>
        <xsd:element name="salary"/>
      </xsd:sequence> 
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
Figure 7 Using minOccurs/maxOccurs
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://example.org/employee/">
  <xsd:element name="employee">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:sequence>
          <xsd:element name="fname/>
          <xsd:choice minOccurs="0">
            <xsd:element name="middle"/>
            <xsd:element name="mi"/>
          </xsd:choice>
          <xsd:element name="lname" maxOccurs="2"/>
        </xsd:sequence>
        <xsd:sequence minOccurs="0" maxOccurs="unbounded">
          <xsd:element name="project"/>
          <xsd:element name="role"/>
        </xsd:sequence>        
      </xsd:sequence> 
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
Show:
© 2015 Microsoft