I am trying to make an XSD content-type that allows either an attribute or content, but not both simultaneously (or neither). For example, the following would be allowed:
<data cid="my_id" />
<data>TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGh</data>
But the following would not be allowed:
<data cid="my_id">TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGh</data>
<data />
The best attempt I have for this so far allows either but also both/neither.
<xs:complexType name="data">
<xs:simpleContent>
<xs:extension base="xs:base64Binary">
<xs:attribute name="cid" type="xs:string" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
Unfortunately, this is not possible with XSD 1.0. With these requriements, you would have to get help from another schema language, on top of XSD eventually, such as Schematron. XSD 1.1 would allow you to assert a rule to the effect you need; unfortunately, support for XSD 1.1 is quite limited at this time.