架构验证包含布尔值的xml
嗨,我有这样一个xml:架构验证包含布尔值的xml,xml,validation,schema,Xml,Validation,Schema,嗨,我有这样一个xml: <xml><fullname> <name attrib="true"/> <lastname1 attrib="false"/> <lastname2 attrib="false"/></fullname></xml> <xs:unique name="attribcheck"> <xs:selector xpath="name|lastname1|lastn
<xml><fullname>
<name attrib="true"/>
<lastname1 attrib="false"/>
<lastname2 attrib="false"/></fullname></xml>
<xs:unique name="attribcheck">
<xs:selector xpath="name|lastname1|lastname2"/>
<xs:field xpath="@attrib"/>
我需要创建一个模式来验证它,这样它将只允许1个attrib值为“true”(其余必须为false[attrib属性定义为xs:boolean]),因此我在元素fullname中添加了一个唯一的检查,如下所示:
<xml><fullname>
<name attrib="true"/>
<lastname1 attrib="false"/>
<lastname2 attrib="false"/></fullname></xml>
<xs:unique name="attribcheck">
<xs:selector xpath="name|lastname1|lastname2"/>
<xs:field xpath="@attrib"/>
当然,它将检测到存在重复的“true”,但也将检测到重复的“false”。
是否有人知道是否有方法设置对应用唯一约束的值的限制?这意味着我可以确保在任何给定时间,其中只有一个是“true”不支持共现约束-您不能基于另一个元素的值在一个元素上表示条件
这将在年发生变化,但后者仅处于起草阶段,仍在变化中,在一段时间内不会得到广泛实施
但是,如果您使用,它现在已经初步支持XMLSchema1.1。请参阅以确定模式验证所需的版本。谢谢,我想我将尝试使用对模式1.1的初步支持