我有如下的 XML 文件
<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>
关键是我想检查是否有成对的MyAttribute
元素(每对中的 CLASS 和 CODE),例如
<MyAttribute User = "CLASS_FROM_1" System = "CLASS1FROM"/>
<MyAttribute User = "CODE_FROM_1" System = "CODE1FROM"/>
在这种情况下:
<MyAttributes>
<MyAttribute User = "CLASS_FROM_1" System = "CLASS1FROM"/>
<MyAttribute User = "CLASS_FROM_2" System = "CLASS2FROM"/>
<MyAttribute User = "CODE_FROM_2" System = "CODE2FROM"/>
</Attributes>
XML 不正确
是否可以在 XML Schema 1.0 中定义这样的约束(在 XSD 文件中进行验证)?也许改变 XML 的层次结构可以解决问题,但我不能改变 xml 结构。