以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  江湖救急 ,在线等  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=45762)


--  作者:clifflee007
--  发布时间:4/21/2007 9:21:00 AM

--  江湖救急 ,在线等
<feedback>
  <basicinfo width="192" height="160" color="2" address="北京路-上海路" desc="双基色">001</basicinfo>
  <basicinfo width="192" height="160" color="2" address="玉泉营南" desc="双基色">002</basicinfo>
  <basicinfo width="192" height="128" color="2" address="航天桥" desc="双基色">004</basicinfo>
 </feedback>
该复杂类型怎么编写

会了。

[此贴子已经被作者于2007-4-21 13:14:34编辑过]

--  作者:gemingke
--  发布时间:4/21/2007 3:47:00 PM

--  
翻翻老贴

我记得是 用simpleContent做扩展


--  作者:gemingke
--  发布时间:4/21/2007 4:29:00 PM

--  
先给一个xml文档的片断:
    <货物价格 单位="元">5670.00</货物价格>

该片断的schema如下:
<xs:element name="货物价格">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="货物价格Type">
     <xs:attribute name="单位" use="required" fixed="元"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
</xs:element>
<xs:simpleType name="货物价格Type">
  <xs:restriction base="xs:decimal">
   <xs:minInclusive value="0"/>
   <xs:totalDigits value="10"/>
   <xs:fractionDigits value="2"/>
  </xs:restriction>
</xs:simpleType>

如上所示,complexType里可以使用complexContent或simpleContent来对某种数据类型进行约束或扩展。上面的例子就是用simpleContent对“货物价格Type”进行扩展的实例。

这里要注意,complexContent的扩展或约束对象必须是complexType,simpleContent的扩展或约束对象必须是simpleType

还要注意一点,complexContent或simpleContent在进行约束或扩展时,都不可以使用刻面 (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDidits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern) ,刻面的使用必须是在simpleType的restriction下面


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms