在W3C SCHOOL网站上发现一个关于Schema的错误

本文详细解析了XML Schema中关于复杂类型和简单类型的使用错误,并提供了正确的修正方法。重点在于理解`complexContent`和`simpleContent`的区别,以及如何正确地定义复杂类型和简单类型。通过一个具体的例子对比了不正确的XML定义和正确的XML定义,帮助读者理解并避免类似的错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原地址是http://www.w3school.com.cn/schema/schema_complex_empty.asp

下面这个例子是不正确的 xmlspy报错。

因为<xs:restriction base="xs:integer">定义的这个integer不是复杂类型,

comlexContent包含的应该是复杂类型,integer不是。所以应该用simpleContent

 

complexContent    定义对复杂类型(包含混合内容或仅包含元素)的扩展或限制。

simpleContent    包含对 complexType 元素的扩展或限制且不包含任何元素。

 

 

 

<xs:element name="product">

  <xs:complexType>

    <xs:complexContent>

      <xs:restriction base="xs:integer">

        <xs:attribute name="prodid" type="xs:positiveInteger"/>

      </xs:restriction>

    </xs:complexContent>

  </xs:complexType>

</xs:element>

 

 

 

下面这个是正确的

<xs:element name="product"> 

    <xs:complexType>  

        <xs:simpleContent>   

            <xs:extension base="xs:integer">    

                <xs:attribute name="prodid" type="xs:positiveInteger"/>  

            </xs:extension>  

        </xs:simpleContent> 

    </xs:complexType>

</xs:element>

转载于:https://www.cnblogs.com/or2-/p/3452465.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值