学习xsd 3

5、只包含属性,不包含内容,也不包含元素
<xsd:element>
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:attribute type="xsd:string"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
效果等同与2

6、只包含属性和子元素,不包含内容
<xsd:element>
<xsd:complexType>
<xsd:complexContent>
<xsd:element name=""/>
<xsd:attribute name=""/>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:complexContent>可缺省
6、注释


<xsd:annotation>

<xsd:documentation xml:lang=”en”>

Element declared with anonymous type

</xsd:documentation>

</xsd:annotation>


元素出现的顺序定义:
<xsd:all>定义元素可按任意顺序出现,且每个元素只出现一次
<xsd:choice>定义子元素中可以出现一个或者另一个
<xsd:sequence>定义子元素必须按照顺序出现
<xsd:sequence>
<xsd:element name="" type="" maxOccurs="10" minOccurs="1">
定义元素出现的最大次数和最小次数

组:
用来定义相关的一组元素

<xs:group name="persongroup">

<xs:sequence>

<xs:element name="firstname" type="xs:string"/>

<xs:element name="lastname" type="xs:string"/>

<xs:element name="birthday" type="xs:date"/>

</xs:sequence>

</xs:group>

用法:
<xs:complexType name="personinfo">

<xs:sequence>

<xs:group ref="persongroup"/>

<xs:element name="country" type="xs:string"/>

</xs:sequence>

</xs:complexType>
用来定义一组相关的属性

<xs:attributeGroup name="personattrgroup">

<xs:attribute name="firstname" type="xs:string"/>

<xs:attribute name="lastname" type="xs:string"/>

<xs:attribute name="birthday" type="xs:date"/>

</xs:attributeGroup>

<xs:element name="person">

<xs:complexType>

<xs:attributeGroup ref="personattrgroup"/>

</xs:complexType>

</xs:element>
Any关键字

表示可以有任意元素

<xs:element name="person">

<xs:complexType>

<xs:sequence>

<xs:element name="firstname" type="xs:string"/>

<xs:element name="lastname" type="xs:string"/>

<xs:any minOccurs="0"/>

</xs:sequence>

</xs:complexType>

</xs:element>

anyAttribute关键字

<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:anyAttribute/>

</xs:complexType>

</xs:element>

substitutionGroup关键字

表示某一个元素和另一个替代元素定义相同

<xs:element name="name" type="xs:string"/>

<xs:element name="navn" substitutionGroup="name"/>

<xs:complexType name="custinfo">

<xs:sequence>

注意事项:
xsd:complexType有两个,站点下的文件路径,attribute在opencms中必须有
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值