xml架构检查限制枚举值是否只有一次
发布时间:2020-12-16 23:09:20 所属栏目:百科 来源:网络整理
导读:我正在创建一个xsd架构来验证某些xml 我想限制xml,因此两次输入相同的项目是不可能的: branches brancheBank/branche brancheBank/branche/branches 但是使用2个不同的项目必须是可行的: branches brancheBank/branche brancheInsurance/branche/branches
我正在创建一个xsd架构来验证某些xml
我想限制xml,因此两次输入相同的项目是不可能的: <branches> <branche>Bank</branche> <branche>Bank</branche> </branches> 但是使用2个不同的项目必须是可行的: <branches> <branche>Bank</branche> <branche>Insurance</branche> </branches> 所以我有以下代码: <!-- definition of simple elements --> <xs:simpleType name="branche"> <xs:restriction base="xs:string"> <xs:enumeration value="Bank" maxOccurs="1"/> <xs:enumeration value="Insurance" maxOccurs="1"/> </xs:restriction> </xs:simpleType> <xs:element name="branches" minOccurs="0"> <!-- minOccurs becouse i want it to be posible to leave out the whole <branches> tag --> <xs:complexType> <xs:sequence> <xs:element name="branche" type="branche" minOccurs="0" maxOccurs="2" /> </xs:sequence> </xs:complexType> </xs:element> 使用maxOccurs =“1”不会将其限制为只有一个值,因为’branche’标记可以出现两次. 我希望值(< branche>值< / branche>)是唯一的. 日Thnx! 解决方法
请参阅有关身份约束的示例
here.类似于:
<xs:element name="branches" ...> <xs:unique name="..."> <xs:selector xpath="branche"/> <xs:field xpath="."/> </xs:key> </xs:element> 不太确定语法,但你明白了. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |