2

I am wondering if there is a way to restrict what validates using one element to check another element. In the example below, is it possible to check a restriction that if OptionOne is selected as "B", then RefIssue will have to be selected as "XXXX-B-XXX" and vice versa?

I have looked into key / refkey, but I was not able to figure out if it could do this constraint. Any help appreciated.

<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="CustomIssueSchema"> <xs:complexType> <xs:sequence> <xs:element name="CustomIssue" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="CustomArgs" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="OptionOne"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="A"/> <xs:enumeration value="B"/> <xs:enumeration value="C"/> </xs:restriction> </xs:simpleType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="CustomRef" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="RefIssue"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="XXXX-A-XXX"/> <xs:enumeration value="XXXX-B-XXX"/> <xs:enumeration value="XXXX-C-XXX"/> </xs:restriction> </xs:simpleType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> 

2 Answers 2

1

This is not possible in XML schema. You cannot have cross-element constraints of this sort, you will have to use another language (Schematron, XQuery, etc) or write code.

Sign up to request clarification or add additional context in comments.

Comments

0

looks like you can do it with XSD 1.1, but it is not released and there are no implementations of it I can use.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.