如何使xml模式中的属性唯一?
发布时间:2020-12-16 07:43:03 所属栏目:百科 来源:网络整理
导读:我想使一个元素的属性像主键一样是唯一的.怎么做呢 这样的事情应该有效: xs:element name="books" maxOccurs="unbounded" xs:complexType xs:sequence xs:element name="book" maxOccurs="unbounded" xs:complexType xs:attribute name="isbn" type="xs:str
我想使一个元素的属性像主键一样是唯一的.怎么做呢
这样的事情应该有效:
<xs:element name="books" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="book" maxOccurs="unbounded"> <xs:complexType> <xs:attribute name="isbn" type="xs:string"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> <xs:unique name="unique-isbn"> <xs:selector xpath="book"/> <xs:field xpath="@isbn"/> </xs:unique> </xs:element> 基本上,您可以使用< xs:unique>定义“唯一性”约束.元素,并定义这个唯一性应该适用的XPath. 有关更多信息,请参阅W3Schools entry on (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |