You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Th...@homag.de on 2002/04/16 12:06:34 UTC

Problem with recursive and derived elements

I'd like to use following schema (dummy.xsd):


<?xml version="1.0" encoding="UTF-8"?>


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:pr="http://www.homag.de/proresult"
     targetNamespace="http://www.homag.de/proresult"
     elementFormDefault="qualified"
     attributeFormDefault="unqualified">


  <xs:attributeGroup name="AttrDERIVED1">
    <xs:attribute name="Derived1Name"                       type
="xs:string"                    use="required"/>
  </xs:attributeGroup>

  <xs:complexType name="DERIVED1">
    <xs:complexContent>
      <xs:extension base="pr:BASE">
        <xs:attributeGroup ref="pr:AttrDERIVED1"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>



  <xs:attributeGroup name="AttrDERIVED2">
    <xs:attribute name="Derived2Name"                       type
="xs:string"                    use="required"/>
  </xs:attributeGroup>

  <xs:complexType name="DERIVED2">
    <xs:complexContent>
      <xs:extension base="pr:BASE">
        <xs:attributeGroup ref="pr:AttrDERIVED2"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>




  <xs:attributeGroup name="AttrDERIVED3">
    <xs:attribute name="Derived3Name"                       type
="xs:string"                    use="required"/>
  </xs:attributeGroup>

  <xs:complexType name="DERIVED3">
    <xs:complexContent>
      <xs:extension base="pr:BASE">
        <xs:attributeGroup ref="pr:AttrDERIVED3"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>




  <xs:attributeGroup name="AttrBASE">
    <xs:attribute name="BaseName"                           type
="xs:string"                    use="required"/>
  </xs:attributeGroup>

  <xs:complexType name="BASE">
    <xs:sequence
      minOccurs="0" maxOccurs="unbounded">
      <xs:element name="BASE"                               type="pr:BASE"
minOccurs="0" maxOccurs="1"/>
    </xs:sequence>
    <xs:attributeGroup ref="pr:AttrBASE"/>
  </xs:complexType>



  <xs:element name="PRORESULT">
    <xs:complexType>
      <xs:all>
        <xs:element name="BASE"                             type="pr:BASE"
minOccurs="0" maxOccurs="1"/>
      </xs:all>
    </xs:complexType>
  </xs:element>

</xs:schema>


There are a base type ("BASE") and  3 derived types
("DERIVED1".."DERIVED3").
A BASE type can contain itself recursively.


Calling the XERCES parser (V.1.7.0, latest stable version) with the xml
file below (pparse -v=always -n -s -f dummy.xml) causes an error:
 Message: Type 'pr:DERIVED3' that is used in xsi:type is not derived from
the type of element 'BASE'


<?xml version="1.0" encoding="iso-8859-1"?>
<pr:PRORESULT xmlns:pr="http://www.homag.de/proresult"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://www.homag.de/proresult
dummy.xsd">

  <pr:BASE xsi:type="pr:DERIVED1" BaseName="Base" Derived1Name="Derived1a">
    <pr:BASE xsi:type="pr:DERIVED2" BaseName="Base" Derived2Name
="Derived2a">
      <pr:BASE xsi:type="pr:DERIVED3" BaseName="Base" Derived3Name
="Derived3a">
      </pr:BASE>
    </pr:BASE>
  </pr:BASE>
</pr:PRORESULT>


Using element DERIVED2 instead of DERIVED3 works.


My questions are:
1. Is it allowed to use recursive types containing itself?
2. Are there limits for derivations?
3. Or is it a Xerces bug?


Thanks in advance.


Regards
Thomas


Thomas.Rothfuss@homag.de


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Problem with recursive and derived elements

Posted by Khaled Noaman <kn...@ca.ibm.com>.
Your schema is fine. It is a Xerces bug.
Would you please open a bugzilla bug for it?

Khaled

Thomas.Rothfuss@homag.de wrote:

> I'd like to use following schema (dummy.xsd):
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>      xmlns:pr="http://www.homag.de/proresult"
>      targetNamespace="http://www.homag.de/proresult"
>      elementFormDefault="qualified"
>      attributeFormDefault="unqualified">
>
>   <xs:attributeGroup name="AttrDERIVED1">
>     <xs:attribute name="Derived1Name"                       type
> ="xs:string"                    use="required"/>
>   </xs:attributeGroup>
>
>   <xs:complexType name="DERIVED1">
>     <xs:complexContent>
>       <xs:extension base="pr:BASE">
>         <xs:attributeGroup ref="pr:AttrDERIVED1"/>
>       </xs:extension>
>     </xs:complexContent>
>   </xs:complexType>
>
>   <xs:attributeGroup name="AttrDERIVED2">
>     <xs:attribute name="Derived2Name"                       type
> ="xs:string"                    use="required"/>
>   </xs:attributeGroup>
>
>   <xs:complexType name="DERIVED2">
>     <xs:complexContent>
>       <xs:extension base="pr:BASE">
>         <xs:attributeGroup ref="pr:AttrDERIVED2"/>
>       </xs:extension>
>     </xs:complexContent>
>   </xs:complexType>
>
>   <xs:attributeGroup name="AttrDERIVED3">
>     <xs:attribute name="Derived3Name"                       type
> ="xs:string"                    use="required"/>
>   </xs:attributeGroup>
>
>   <xs:complexType name="DERIVED3">
>     <xs:complexContent>
>       <xs:extension base="pr:BASE">
>         <xs:attributeGroup ref="pr:AttrDERIVED3"/>
>       </xs:extension>
>     </xs:complexContent>
>   </xs:complexType>
>
>   <xs:attributeGroup name="AttrBASE">
>     <xs:attribute name="BaseName"                           type
> ="xs:string"                    use="required"/>
>   </xs:attributeGroup>
>
>   <xs:complexType name="BASE">
>     <xs:sequence
>       minOccurs="0" maxOccurs="unbounded">
>       <xs:element name="BASE"                               type="pr:BASE"
> minOccurs="0" maxOccurs="1"/>
>     </xs:sequence>
>     <xs:attributeGroup ref="pr:AttrBASE"/>
>   </xs:complexType>
>
>   <xs:element name="PRORESULT">
>     <xs:complexType>
>       <xs:all>
>         <xs:element name="BASE"                             type="pr:BASE"
> minOccurs="0" maxOccurs="1"/>
>       </xs:all>
>     </xs:complexType>
>   </xs:element>
>
> </xs:schema>
>
> There are a base type ("BASE") and  3 derived types
> ("DERIVED1".."DERIVED3").
> A BASE type can contain itself recursively.
>
> Calling the XERCES parser (V.1.7.0, latest stable version) with the xml
> file below (pparse -v=always -n -s -f dummy.xml) causes an error:
>  Message: Type 'pr:DERIVED3' that is used in xsi:type is not derived from
> the type of element 'BASE'
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <pr:PRORESULT xmlns:pr="http://www.homag.de/proresult"
>                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>                xsi:schemaLocation="http://www.homag.de/proresult
> dummy.xsd">
>
>   <pr:BASE xsi:type="pr:DERIVED1" BaseName="Base" Derived1Name="Derived1a">
>     <pr:BASE xsi:type="pr:DERIVED2" BaseName="Base" Derived2Name
> ="Derived2a">
>       <pr:BASE xsi:type="pr:DERIVED3" BaseName="Base" Derived3Name
> ="Derived3a">
>       </pr:BASE>
>     </pr:BASE>
>   </pr:BASE>
> </pr:PRORESULT>
>
> Using element DERIVED2 instead of DERIVED3 works.
>
> My questions are:
> 1. Is it allowed to use recursive types containing itself?
> 2. Are there limits for derivations?
> 3. Or is it a Xerces bug?
>
> Thanks in advance.
>
> Regards
> Thomas
>
> Thomas.Rothfuss@homag.de
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org