XSD - one of 2 attributes is required?

XSD 1.1 will let you do this using asserts.

<xsd:element name="remove">
    <xsd:complexType>                        
        <xsd:attribute name="ref" use="optional"/>
        <xsd:attribute name="uri" use="optional"/>
        <xsd:assert test="(@ref and not(@uri)) or (not(@ref) and @uri)"/>            
    </xsd:complexType>
</xsd:element>

No, I don't think you can do that with attributes. You could wrap two <xs:element> into a <xs:choice> - but for attributes, there's no equivalent construct, I'm afraid.

Tags:

Xsd