繁体   English   中英

限制XML模式中的属性值

[英]Restrict attribute values in XML schema

是否可以限制XML模式中属性值的组合? 我有一个带有两个属性的标签,我想允许它们的值进行某些组合。 例如,如果attribute_1的值为“ A”,则attribute_2的值不得为“ B”。

在XSD 1.1中,可以使用断言 像(未经测试的):

<xs:element name="SomeType">
  <xs:complexType>
    <xs:attribute name="attribute_1" type="xs:string">
    <xs:attribute name="attribute_2" type="xs:string"/>
    <xs:assert test="if (@attribute_1 = 'A') then @attribute_2 != 'B' else true()"/>
  </xs:complexType>
</xs:element>

在这里查看更多示例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM