You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Elsa Yañez Morante <el...@catastro.meh.es> on 2007/06/11 13:07:39 UTC

bug: restriction of a choice particle

Hello,

 

We are working with XML Schemas and we have detected that, using Xerces' validation, there are some errors that don't appear if we use other tools to validate our schemas.

 

Errors happen when we have a base type that contains a choice particle followed by sequence or choice particles and we want to define a restricted type. Xerces only allow one element in those sequence or choice particles. But all the elements should be allowed.

 

This is an example:

 

-         This is the base type, that contains a choice particle followed by two sequence particles:

 

<xsd:complexType name="base">            

    <xsd:choice>

            <xsd:sequence minOccurs="0">                                              

                        <xsd:element name="a" type="xsd:string" minOccurs="0"/>

                        <xsd:element name="b" type="xsd:string" minOccurs="0"/>

                        <xsd:element name="c" type="xsd:string" minOccurs="0"/>

                        <xsd:element name="d" type="xsd:string" minOccurs="0"/>

                        <xsd:element name="e" type="xsd:string" minOccurs="0"/>

                        <xsd:element name="f" type="xsd:string" minOccurs="0"/>

                        <xsd:element name="g" type="xsd:string" minOccurs="0"/>

                        <xsd:element name="h" type="xsd:string" minOccurs="0"/>

                        <xsd:element name="i" type="xsd:string" minOccurs="0"/>

            </xsd:sequence>

             <xsd:sequence minOccurs="0">                                             

                        <xsd:element name="j" type="xsd:string" minOccurs="0"/>

                        <xsd:element name="k" type="xsd:string" minOccurs="0"/>

             </xsd:sequence>

    </xsd:choice>                

</xsd:complexType>

 

 

 

-         This is a restricted type that contains the same choice particle followed only by one of the sequence particles. Xerces find errors at this type.

 

<xsd:complexType name="restricted1"> 

   <xsd:complexContent>

        <xsd:restriction base="base">

            <xsd:choice>

                <xsd:sequence>

                    <xsd:element name="j" type="xsd:string"/>

                    <xsd:element name="k" type="xsd:string"/>

                </xsd:sequence>                        

            </xsd:choice>

         </xsd:restriction>

    </xsd:complexContent>

</xsd:complexType>

 

These are the errors that Xerces find:

rcase-MapAndSum.2: Group's occurrence range, (2,2), is not a valid restriction of base group's occurrence range, (1,1).

 

derivation-ok-restriction.5.4.2: Error for type 'restricted1'.  The particle of the type is not a valid restriction of the particle of the base.

 

 

-         This is another restricted type. Xerces doesn't find errors at it because the sequence particle only contains one element.

 

<xsd:complexType name="restricted2"> 

   <xsd:complexContent>

        <xsd:restriction base="base">

            <xsd:choice>

                <xsd:sequence>

                    <xsd:element name="j" type="xsd:string"/>                    

                </xsd:sequence>                        

            </xsd:choice>

         </xsd:restriction>

    </xsd:complexContent>

</xsd:complexType>

 

 

 

We believe this is caused by a Xerces' bug because we think that our schema is valid according to W3C Recommendation (http://www.w3.org/TR/xmlschema-1/ <http://www.w3.org/TR/xmlschema-1/> ). Could you tell us if we are right?

 

Thank you very much.

**********************************************************************************************
PAntes de imprimir este e-mail piense bien si es necesario hacerlo: El medioambiente es cosa de todos 

********************* Aviso Legal ********************* 
Este mensaje y cualquier fichero adjunto está dirigido únicamente a sus destinatarios 
 y contiene información confidencial. Si usted considera que ha recibido este correo 
electrónico por error (por el asunto, por el remitente o por cualquier otra causa), le 
informamos que cualquier revisión, alteración, impresión, copia o transmisión de este 
mensaje o de cualquier fichero adjunto está prohibida y puede constituir un acto ilegal. 
Por favor, notifíquele el error al remitente respondiendo a este e-mail y elimine 
el mensaje y su contenido inmediatamente. El Ministerio de Economía y Hacienda se 
reserva las acciones legales que le correspondan contra todo tercero que acceda de 
forma ilegítima al contenido de cualquier mensaje externo procedente del mismo. 

********************* Disclaimer ********************* 
This e-mail and any files transmitted with it are intended solely for the use of the 
intended recipients and may contain confidential information. If it appears (from the 
subject matter or address information or otherwise) that you received this email in error, 
please note that any review, dissemination, disclosure, alteration, printing, copying or 
transmission of this e-mail or any file transmitted with it is prohibited and may be 
unlawful. Please notify us by return email and delete this email and its contents 
immediately. Spanish Ministry of Finances may take any legal action, according with 
the illegal access to the content of any external message from the Ministry.

**********************************************************************************************

Re: bug: restriction of a choice particle

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Elsa,

XML Schema 1.0 disallows many restrictions which intuitively look valid. 
This appears to be one of them.

If you follow the MapAndSum constraint [1] in the Structures spec you'll 
find that in order for your type to be a valid restriction, the product of 
maxOccurs of the sequence in the derived type and the number of particles 
in the sequence in the derived type must be less than or equal to the 
maxOccurs of the choice on the base type. That isn't satisfied here 
([R.maxOccurs = 1] * [R.particles.count = 2] > [B.maxOccurs = 1]). Perhaps 
the tools you've used aren't checking this constraint to the letter of the 
spec.

Thanks.

[1] http://www.w3.org/TR/xmlschema-1/#rcase-MapAndSum

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Elsa Yañez Morante <el...@catastro.meh.es> wrote on 06/11/2007 
07:07:39 AM:

> Hello,
> 
> We are working with XML Schemas and we have detected that, using 
> Xerces? validation, there are some errors that don?t appear if we 
> use other tools to validate our schemas.
> 
> Errors happen when we have a base type that contains a choice 
> particle followed by sequence or choice particles and we want to 
> define a restricted type. Xerces only allow one element in those 
> sequence or choice particles. But all the elements should be allowed.
> 
> This is an example:
> 
> -         This is the base type, that contains a choice particle 
> followed by two sequence particles:
> 
> <xsd:complexType name="base">            
>     <xsd:choice>
>             <xsd:sequence 
> minOccurs="0">                                              
>                         <xsd:element name="a" type="xsd:string" 
> minOccurs="0"/>
>                         <xsd:element name="b" type="xsd:string" 
> minOccurs="0"/>
>                         <xsd:element name="c" type="xsd:string" 
> minOccurs="0"/>
>                         <xsd:element name="d" type="xsd:string" 
> minOccurs="0"/>
>                         <xsd:element name="e" type="xsd:string" 
> minOccurs="0"/>
>                         <xsd:element name="f" type="xsd:string" 
> minOccurs="0"/>
>                         <xsd:element name="g" type="xsd:string" 
> minOccurs="0"/>
>                         <xsd:element name="h" type="xsd:string" 
> minOccurs="0"/>
>                         <xsd:element name="i" type="xsd:string" 
> minOccurs="0"/>
>             </xsd:sequence>
>              <xsd:sequence 
> minOccurs="0">                                             
>                         <xsd:element name="j" type="xsd:string" 
> minOccurs="0"/>
>                         <xsd:element name="k" type="xsd:string" 
> minOccurs="0"/>
>              </xsd:sequence>
>     </xsd:choice>                
> </xsd:complexType>
> 
> 
> 
> -         This is a restricted type that contains the same choice 
> particle followed only by one of the sequence particles. Xerces find
> errors at this type.
> 
> <xsd:complexType name="restricted1"> 
>    <xsd:complexContent>
>         <xsd:restriction base="base">
>             <xsd:choice>
>                 <xsd:sequence>
>                     <xsd:element name="j" type="xsd:string"/>
>                     <xsd:element name="k" type="xsd:string"/>
>                 </xsd:sequence>                        
>             </xsd:choice>
>          </xsd:restriction>
>     </xsd:complexContent>
> </xsd:complexType>
> 
> These are the errors that Xerces find:
> rcase-MapAndSum.2: Group's occurrence range, (2,2), is not a valid 
> restriction of base group's occurrence range, (1,1).
> 
> derivation-ok-restriction.5.4.2: Error for type 'restricted1'.  The 
> particle of the type is not a valid restriction of the particle of the 
base.
> 
> 
> -         This is another restricted type. Xerces doesn?t find 
> errors at it because the sequence particle only contains one element.
> 
> <xsd:complexType name="restricted2"> 
>    <xsd:complexContent>
>         <xsd:restriction base="base">
>             <xsd:choice>
>                 <xsd:sequence>
>                     <xsd:element name="j" type="xsd:
> string"/>                    
>                 </xsd:sequence>                        
>             </xsd:choice>
>          </xsd:restriction>
>     </xsd:complexContent>
> </xsd:complexType>
> 
> 
> 
> We believe this is caused by a Xerces? bug because we think that our
> schema is valid according to W3C Recommendation (http://www.w3.
> org/TR/xmlschema-1/). Could you tell us if we are right?
> 
> Thank you very much.
> P Antes de imprimir este e-mail piense bien si es necesario hacerlo:
> El medioambiente es cosa de todos 
> Before printing this email, assess if it is really needed.

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org