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

Re: XSD with "required" attribute option related query

From: Rajneesh Shukla <rajneeshshukla@gmail.com>
Date: Tue, 25 Feb 2020 12:59:28 +0530
Message-ID: <CAFAat38FpJ0gv1FBwTNpLCz==yDDE3egA7yxc=nJDnPe_oodvQ@mail.gmail.com>
To: Mukul Gandhi <gandhi.mukul@gmail.com>
Cc: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Hello Mukul,

Thanks for your time and response.
I tried your recommended steps with xml 1.0, but in vain.

It seems it is not allowed:

Below is XSD after replacement:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="functionalView">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="columns">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="column" maxOccurs="unbounded" minOccurs="1">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:string">
                      <xs:attribute type="xs:string" name="name"
use="required"/>
                      <xs:attribute type="xs:string" name="columnAlias"
use="required"/>
                      <xs:attribute type="xs:string" name="description"
use="required"/>
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="fromviews" maxOccurs="1" minOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="fromview" maxOccurs="unbounded"
minOccurs="2">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:string">
                      <xs:attribute type="xs:string" name="name"
use="required"/>
                      <xs:attribute type="xs:string" name="alias"
use="required"/>
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="joins" maxOccurs="1" minOccurs="1">
          <xs:complexType>
            <xs:choice maxOccurs="unbounded" minOccurs="1">
              <xs:element name="join" maxOccurs="unbounded" minOccurs="0">
                <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="condition"
use="required"/>
                      <xs:attribute type="xs:string" name="alias2"
use="required"/>
                      <xs:attribute type="xs:string" name="col2"
use="required"/>
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
              <xs:element name="leftouterjoin" maxOccurs="unbounded"
minOccurs="0">
                <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="condition"
use="required"/>
                      <xs:attribute type="xs:string" name="alias2"
use="required"/>
                      <xs:attribute type="xs:string" name="col2"
use="required"/>
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
            </xs:choice>
          </xs:complexType>
        </xs:element>
        <xs:element name="where" maxOccurs="1" minOccurs="0">
    <xs:complexType>
         <xs:choice>
              <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="required"/>
                      <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: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="required"/>
                              <xs:attribute type="xs:string" name="date"
use="optional"/>
                          </xs:extension>
                       </xs:simpleContent>
                     </xs:complexType>
                </xs:element>
                <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="required"/>
                            </xs:extension>
                         </xs:simpleContent>
                      </xs:complexType>
                 </xs:element>
            </xs:choice>
          </xs:complexType>
     </xs:element>
      </xs:sequence>
      <xs:attribute type="xs:string" name="name"/>
      <xs:attribute type="xs:string" name="description"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

Below is error message received where tried to register it with Oracle 12c
db:

ORA-31154: invalid XML document
ORA-19202: Error occurred in XML processing
LSX-00102: duplicate element "condition"
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 72
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 33
ORA-06512: at line 132
31154. 00000 -  "invalid XML document"
*Cause:    The XML document is invalid with respect to its XML Schema.
*Action:   Fix the errors identified and try again.

Thanks,
Rajneesh


On Tue, 25 Feb 2020 at 06:54, Mukul Gandhi <gandhi.mukul@gmail.com> wrote:

> Hi Rajneesh,
>     It seems to me that, this issue may be solved with XML Schema 1.0 as
> well.
>
> Within your schema document, please try replacing following XSD element
> declaration,
>
> <xs:element name="where" maxOccurs="1" minOccurs="0">
>     ...
>
> with
>
> <xs:element name="where" maxOccurs="1" minOccurs="0">
>     <xs:complexType>
>          <xs:choice>
>               <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="required"/>
>                       <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: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="required"/>
>                               <xs:attribute type="xs:string" name="date"
> use="optional"/>
>                           </xs:extension>
>                        </xs:simpleContent>
>                      </xs:complexType>
>                 </xs:element>
>                 <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="required"/>
>                             </xs:extension>
>                          </xs:simpleContent>
>                       </xs:complexType>
>                  </xs:element>
>             </xs:choice>
>           </xs:complexType>
>      </xs:element>
>
> I've replaced one of the <sequence> with <choice>.
>
> On Mon, Feb 24, 2020 at 1:39 PM Rajneesh Shukla <rajneeshshukla@gmail.com>
> wrote:
>
>
>> I am  working inside the database, it won't be possible.
>>
>> Oracle XML DB only supports XML Schema 1.0.
>>
>
>
>
> --
> Regards,
> Mukul Gandhi
>
Received on Tuesday, 25 February 2020 07:29:52 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 25 February 2020 07:29:53 UTC