混合的差异=“真"和 xs:extension in XML Schema [英] Difference of mixed="true" and xs:extension in XML Schema

查看:34
本文介绍了混合的差异=“真"和 xs:extension in XML Schema的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两者之间的实际区别是什么:

What is the practical diference between these two:

<xs:element name="A">
 <xs:complexType mixed="true">
  <xs:attribute name="att" type="xs:boolean"/>
 </xs:complexType>
</xs:element>

<xs:element name="B">
 <xs:complexType>
  <xs:simpleContent>
   <xs:extension base="xs:string">
    <xs:attribute name="att" type="xs:boolean"/>
   </xs:extension>
  </xs:simpleContent>
 </xs:complexType>
</xs:element>

推荐答案

两者是不同的.您的第一个示例使用 mixed="true" 表示混合内容,即与子元素混合的字符数据.而您的第二个示例将元素内容限制为 xs:string 类型.两者都表示一个属性的存在.

The two are different. Your first example uses mixed="true" which denotes mixed content, i.e. character data mixed in with child elements. Whereas your second example restricts the element content to the xs:string type. Both indicate the presence of an attribute.

就您的示例而言,两者实际上是相同的.但是,如果您不打算混合内容,即您不打算添加子元素,那么第二个版本会更清晰.

With your example, both are practically the same. However, if you do not plan on having mixed content, i.e. you do not plan to add child elements, the second version is much clearer.

这篇关于混合的差异=“真"和 xs:extension in XML Schema的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆