PREVIOUS UP  Technologies Internet et Education, © TECFA
  7. Traduire des DTDs vers XSD

7. Traduire des DTDs vers XSD

7.1 Définition d’éléments

Exemples de http://www.w3.org/2000/04/schema_hack/

 

DTD

XML Schema

<!ELEMENT ROOT

( A, B ) >

<element name="ROOT">
<complexType content="elementOnly">
<element ref="t:A">
<element ref="t:B">
</complexType>
<element>

<!ELEMENT ROOT

(A | B) >

<element name="ROOT">
<complexType content="elementOnly">
< choice >
<element ref="t:A">
<element ref="t:B">
< /choice >
</complexType>
<element>

<!ELEMENT ROOT

(A | (B , C)) >

<element name="ROOT">
<complexType content="elementOnly">
< choice >
<element ref="t:A">
< sequence >
<element ref="t:B">
<element ref="t:C">
< /sequence >
< /choice >
</complexType>
<element>

<!ELEMENT ROOT

(A ? ,B + ,C * ) >

<element name="ROOT">
<complexType content="elementOnly">
<element ref="t:A" minOccurs ="0">
<element ref="t:B" maxOccurs ="unbounded">
<element ref="t:C" minOccurs="0" maxOccurs="unbounded ">
</complexType>
<element>

7.2 Définition d’attributs

DTD

XML Schema

<! ATTLIST ROOT

a CDATA #REQUIRED >

<element name="ROOT">
<complexType content="elementOnly">
< attribute name ="a" type=" string " use=" required "/>
</complexType>
</element>

<!ATTLIST ROOT

a CDATA #IMPLIED >

<element name="ROOT">
<complexType content="elementOnly">
<attribute name="a" type="string" use=" optional "/>
</complexType>
</element>

<!ATTLIST ROOT

a ( x|y|z) #REQUIRED;>

<element name="ROOT">
<complexType content="elementOnly">
<attribute name="a">
<simpleType base="string">
<enumeration value="x"/>
<enumeration value="y"/>
<enumeration value="z"/>
</simpleType>
</attribute>
</complexType>
</element>

<!ATTLIST ROOT

a CDATA #FIXED " x ">

<element name="ROOT">
<complexType content="elementOnly">
<attribute name="a" type="string"
use=" fixed " value=" x "/>
</complexType>

</element>

7.3 Exemples

Voir: http://tecfa.unige.ch/guides/xml/examples/xsd-examples/


PREVIOUSUP -- TIE