I have the following scheme that I use to ensure that the person PhoneNumber and PhoneNumberType (Home, Job, etc.) are no longer than 10 characters. However, I want to improve this scheme so that PhoneNumberType not required if PhoneNumber not provided, but is required if PhoneNumber provided. Is there a way to do this in XML Schema 1.0?
I know that this can be done in XML Schema 1.1 using <xs:assert/> , but unfortunately I stick with XML Schema 1.0.
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xs:element name="PhoneNumber"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="0"/> <xs:maxLength value="10"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="PhoneNumberType"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="0"/> <xs:maxLength value="10"/> </xs:restriction> </xs:simpleType> </xs:element> </xsd:schema>
source share