加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – 如何在复杂类型的xsd文件中使用唯一标记?

发布时间:2020-12-16 23:06:51 所属栏目:百科 来源:网络整理
导读:我已经看到了如何在xsd中的元素声明中直接使用唯一标记的示例,但我无法弄清楚如何放入一个复杂类型的元素声明,请参阅下面的代码: xs:complexType name="flighttype"xs:sequence xs:element name="departure" type="departuretype"/ xs:element name="arriva
我已经看到了如何在xsd中的元素声明中直接使用唯一标记的示例,但我无法弄清楚如何放入一个复杂类型的元素声明,请参阅下面的代码:

<xs:complexType name="flighttype">
<xs:sequence>
    <xs:element name="departure" type="departuretype"/>
    <xs:element name="arrival" type="arrivaltype"/>
    <xs:element name="altitude" type="xs:string"/>
    <xs:element name="speed" type="xs:string"/>
    <xs:element name="distance" type="xs:string"/>
    <xs:element name="entertainment" type="entertainmenttype"/>
    <xs:element name="safetymessage" type="xs:string"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string"/>
<xs:attribute name="airline" type="xs:string"/>
<xs:attribute name="flightno" type="xs:string"/>
<xs:attribute name="model" type="xs:string"/>
<xs:attribute name="passengers" type="xs:integer"/>
<xs:attribute name="status" type="xs:string"/>
</xs:complexType>

我想使id成为唯一的id,我可以使用以下示例,但它直接在元素声明中使用.

Example

谢谢!

解决方法

在XSD中,身份约束与元素相关联,而不与类型相关联.因此,在模式中定义为具有类型flighttype的元素上定义标识约束,而不是在flighttype本身上定义.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读