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

利用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>
posted @ 2013-07-04 09:27  muzizongheng  阅读(378)  评论(0编辑  收藏  举报
如果我们时时忙着展现自己的知识, 将何从忆起成长所需的无知?