I have an attributeGroup defined in my XSD schema. From what I’ve read and tried out, there is no way I could specify the optionality of the usage of whole group (so that either all of the attributes are specified, or none), something like:
<xs:attributeGroup name='NameDesc'> <xs:attribute name='n' type='xs:string' use='required'/> <xs:attribute name='d' type='xs:string' use='required'/> <xs:attribute name='uinf' type='xs:string' use='required'/> </xs:attributeGroup> <xs:complexType name='g'> <xs:attributeGroup ref='tns:NameDesc' use='optional' /> </xs:complexType>
(note the use=’required’ I’ve added in the attributeGroup reference, which is not allowed). Am I right or is there a way to achieve this?
I’ve read How to make "use" attribute (required/optional) depend on another value?, but I’m not sure this applies to my case.
As far as I know (someone please correct me if I’m wrong), it’s impossible to make attributes dependent like that.
Could you consider making the attributeGroup an actual element? That way the whole element could be present or not as a child element.
This would also be a better design if you were mapping your schema to objects.