xml schema 中如何定义类似Map的结构

XML元数据与元素唯一性
本文探讨了如何使用XML的xs:unique关键字确保元素唯一性,通过在xs:element中添加unique节点并指定需要唯一化的领域,实现复杂数据结构中的唯一约束。
<?xml version="1.0" encoding="UTF-8"?> 利用xs:unique关键字。在xs:element里添加unique节点,任意命名,然后用xs:selector来选择需要唯一的域, xs:field 里指定特定的字段。


例如:定义所有Item里的Key为唯一, 




                 <xs:complexType>
                                                 <xs:sequence minOccurs ="0" maxOccurs="unbounded ">
                                                                 <xs:element name ="Item" type="IdentifiersWithSourceItemType">
                                                                 </xs:element>
                                                 </xs:sequence>
                                 </xs:complexType>
                                 <xs:unique name ="KeyUnique">
                                                 <xs:selector xpath =".//Key"/>
                                                 <xs:field xpath =".//NamespaceID"/>
                                 </xs:unique>
                                 <xs:unique name ="KeyUnique2">
                                                 <xs:selector xpath =".//Key"/>
                                                 <xs:field xpath =".//UniversalIDType"/>
                                                 <xs:field xpath =".//Universal/UniversalID"/>
                                 </xs:unique>

转载于:https://www.cnblogs.com/muzizongheng/p/3170920.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值