I would like to have rules embedded within my XSD schema definition for how optional attributes of an element are to be used. Consider the following element definition:
<xs:complexType name="sampleElement">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="description" type="xs:string" use="optional"/>
<xs:attribute name="optPrimary" type="xs:string" use="optional"/>
<xs:attribute name="optSecondary" type="xs:string" use="optional"/>
</xs:complexType
In this example, both optPrimary and optSecondary are indeed optional. The attribute optPrimary can be used by itself, but optSecondary must be used in conjunction with optPrimary. Therefore, I would like a rule embedded in the schema that can be enforced when the XML is validated.
I have found examples of Schematron used for this in a separate file, but I have not found how it can be embedded as part of the schema.