XSD to couple values of two XML elements?
<p>My program can return 2 XMLs like:</p>

<pre><code>&lt;RESPONSE&gt;
    &lt;ERROR_ID&gt;1&lt;/ERROR_ID&gt;
    &lt;ERROR_MESSAGE&gt;Parse error&lt;/ERROR_MESSAGE&gt;
&lt;/RESPONSE&gt;

&lt;RESPONSE&gt;
    &lt;ERROR_ID&gt;2&lt;/ERROR_ID&gt;
    &lt;ERROR_MESSAGE&gt;Unexpected attribute&lt;/ERROR_MESSAGE&gt;
&lt;/RESPONSE&gt;
</code></pre>

<p>I try write some XSD file to validate if they are ok. Here what I end up with:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="qualified"&gt;

    &lt;xsd:element name="RESPONSE" type="Response"/&gt;

    &lt;xsd:complexType name="Response"&gt;
        &lt;xsd:all&gt;
            &lt;xsd:element name="ERROR_ID" type="ErrorId"/&gt;
            &lt;xsd:element name="ERROR_MESSAGE" type="ErrorMessage"/&gt;
        &lt;/xsd:all&gt;
    &lt;/xsd:complexType&gt;

    &lt;xsd:simpleType name="ErrorId"&gt;
        &lt;xsd:restriction base="xsd:positiveInteger"&gt;
            &lt;xsd:enumeration value="1"/&gt;
            &lt;xsd:enumeration value="2"/&gt;
        &lt;/xsd:restriction&gt;
    &lt;/xsd:simpleType&gt;

    &lt;xsd:simpleType name="ErrorMessage"&gt;
        &lt;xsd:restriction base="xsd:string"&gt;
            &lt;xsd:enumeration value="Parse error"/&gt;
            &lt;xsd:enumeration value="Unexpected attribute"/&gt;
        &lt;/xsd:restriction&gt;
    &lt;/xsd:simpleType&gt;

&lt;/xsd:schema&gt;
</code></pre>

<p>It validates fine but I'm thinking if can I link up error id with error message to not let pass validation file where error id=2 will go with message from error with id=1:</p>

<pre><code>&lt;RESPONSE&gt;
    &lt;ERROR_ID&gt;2&lt;/ERROR_ID&gt;
    &lt;ERROR_MESSAGE&gt;Parse error&lt;/ERROR_MESSAGE&gt;
&lt;/RESPONSE&gt;
</code></pre>

<p>There is a good way to do this? My program returns of course a lot more error ids and message. </p>

<p>Maybe a better question is if I should even expect such a validation from XSD?</p>