XSD 仅含元素概述

导读 “仅含元素”的复合类型元素是只能包含其他元素的元素。

XSD 仅含元素概述

复合类型仅包含元素

XML 元素,”person”,仅包含其他的元素:


<person>
<firstname>John</firstname>
<lastname>Smith</lastname>
</person>

您可在 schema 中这样定义 “person” 元素:


<xs:element name="person">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="firstname" type="xs:string"/>
      <xs:element name="lastname" type="xs:string"/>
    </xs:sequence><
  </xs:complexType>
</xs:element>

请留意这个 。它意味着被定义的元素必须按上面的次序出现在 “person” 元素中。

或者您可以为 complexType 元素设定一个名称,并让 “person” 元素的 type 属性来引用此名称(如使用此方法,若干元素均可引用相同的复合类型):


<xs:element name="person" type="persontype"/>
<xs:complexType name="persontype">
  <xs:sequence>
    <xs:element name="firstname" type="xs:string"/>
    <xs:element name="lastname" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

原文来自:https://www.runoob.com/schema/schema-complex-elements.html

本文地址:https://www.linuxprobe.com/xsd-contains-only.html编辑:王艳敏,审核员:逄增宝

Linux命令大全:https://www.linuxcool.com/

Linux系统大全:https://www.linuxdown.com/

红帽认证RHCE考试心得:https://www.rhce.net/

© 版权声明
THE END
喜欢就支持一下吧