简体   繁体   中英

XML Schema Constraint

I have an XML schema that contains the following line.

<Customer Customer_Id = "c5" Age = "24" Years_Of_Membership = "26">

Is it possible for me to make a constraint that the value of Years_Of_Membership must be less than the value of Age?

Thanks

It is not possible to specify these kind of constraints with XSD 1.0.

It should be possible in XSD 1.1 using 'assertions':

<xs:element name="Customer">
  <xs:complexType>
    . . .
    <xs:assert test="@Years_Of_Membership lt @Age" />
  </xs:complexType>
</xs:element>

(I say 'should' because I don't have an XSD 1.1 processor to test it).

It might be possible with other schema technologies like Schematron.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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