从 DTDs 转换到 XML Schemas 时元素和属性的变化

王朝other·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

从 DTDs 转换到 XML Schemas 时元素和属性的变化

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>

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>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航