W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2020

XSD with "required" attribute option related query

From: Rajneesh Shukla <rajneeshshukla@gmail.com>
Date: Fri, 21 Feb 2020 18:32:10 +0530
Message-ID: <CAFAat3-1fsxnQo7-yqc1J0hoEm_=0X+f_Hr9h4XJay-J9d9+Dg@mail.gmail.com>
To: xmlschema-dev@w3.org
Hello All,

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="where" maxOccurs="1" minOccurs="0">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="condition" maxOccurs="unbounded"
minOccurs="1">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:string">
                      <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"/>
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

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.

Thanking you in anticipation !!!

Attachment:
Complete XSD file.

Thanks,
Rajneesh

Received on Friday, 21 February 2020 17:43:45 UTC

This archive was generated by hypermail 2.4.0 : Friday, 21 February 2020 17:43:46 UTC