限制检查XML节点中的元素对

时间:2015-09-29 13:44:46

标签: xml xsd xsd-validation xsd-1.0

我有XML文件,如下所示

301

关键是我想检查是否有成对的 <MyAttributes> <MyAttribute User = "CLASS_FROM_1" System = "CLASS1FROM"/> <MyAttribute User = "CODE_FROM_1" System = "CODE1FROM"/> <MyAttribute User = "CLASS_FROM_2" System = "CLASS2FROM"/> <MyAttribute User = "CODE_FROM_2" System = "CODE2FROM"/> </Attributes> 元素(每对中有CLASS和CODE),例如

MyAttribute

如果是这样的话:

        <MyAttribute User = "CLASS_FROM_1" System = "CLASS1FROM"/>
        <MyAttribute User = "CODE_FROM_1" System = "CODE1FROM"/>

XML不正确

是否可以在XML Schema 1.0中定义此类约束(在XSD文件中进行验证)?也许改变XML的层次结构可以解决问题,但我无法改变xml结构。

0 个答案:

没有答案