0
votes

I am new to XSD and XML and need to explore if there is option to make sure that any one attribute in a set of attributes within same element is required.

Example:

xs:element name="condition" maxOccurs="unbounded" minOccurs="1"

                  xs:attribute type="xs:string" name="alias1" use="required"
                  xs:attribute type="xs:string" name="col1" use="required"
                  xs:attribute type="xs:string" name="operator" use="required"
                  xs:attribute type="xs:string" name="string" use="optional"
                  xs:attribute type="xs:string" name="number" use="optional"
                  xs:attribute type="xs:string" name="date" use="optional"

Here I want to ensure that minimum one attribute in a set of 3 attributes (mentioned as optional in above) are required. All can not be optional , however any one (can be more than one also) is required.

Thanks, Rajneesh

1

1 Answers

1
votes

This can't be done in XSD 1.0. It can be done in XSD 1.1 using assertions, for example

<xs:assert test="count(@alias1, @col1, @operator, ...) ge 1"/>