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

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 net_lover 的 blog

从 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>

本文关键:DTD,XML,SCHEMAS
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top