以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  Schema  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=21315)


--  作者:zhuxiang
--  发布时间:8/21/2005 12:58:00 PM

--  Schema
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">

<xs:simpleType name="type1">
<xs:restriction base="xs:int"/>
</xs:simpleType>

<xs:complexType name="type2">
 <xs:simpleContent>
  <xs:extension base="type1"/>
 </xs:simpleContent>
</xs:complexType>

<xs:complexType name="type3">
 <xs:simpleContent>
  <xs:restriction base="type1"/>
 </xs:simpleContent>
</xs:complexType>

<xs:complexType name="type4">
 <xs:simpleContent>
  <xs:restriction base="type2"/>
 </xs:simpleContent>
</xs:complexType>

</xs:schema>
以个定义了四个类型,为什么type3会出错呢?restriction到底是什么意思?


--  作者:fengzhiyi
--  发布时间:8/26/2005 10:23:00 AM

--  
restriction创建这样一个数据类型:该类型是一个已有的数据类型的子集。如整数型的一个子集“2-5”,就可以用restriction限定。她只用于简单数据类型中,你在type3中的simpleContent是对原来数据类型的扩展,在这里无法限定原type1类型,所以你的文档是错误的,你可以改为extension,要看你真正想表达的意思是什么了。
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
31.250ms