Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含以下行的 XML 模式。
<Customer Customer_Id = "c5" Age = "24" Years_Of_Membership = "26">
我是否可以限制 Years_Of_Membership 的值必须小于 Age 的值?
谢谢
无法使用 XSD 1.0 指定这些类型的约束。
在 XSD 1.1 中应该可以使用“断言”:
<xs:element name="Customer"> <xs:complexType> . . . <xs:assert test="@Years_Of_Membership lt @Age" /> </xs:complexType> </xs:element>
(我说“应该”是因为我没有 XSD 1.1 处理器来测试它)。
其他模式技术(如 Schematron)可能是可能的。