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 David North <dt...@corefiling.co.uk> on 2010/03/10 12:45:41 UTC

Extending complex types with mixed content

Hi,

We think we have discovered an anomaly in Xerces' interpretation of the
XML schema structures specification.

Clause 1.4.3.2.2.1 of http://www.w3.org/TR/xmlschema-1/#cos-ct-extends
specifies that when deriving a new complex type by extension from an
existing complex type, then: "Both {content type}
<http://www.w3.org/TR/xmlschema-1/#content_type>s must be /mixed/ or
both must be /element-only/".

As demonstrated by the following schema, Xerces-J does not raise an
error despite the extension of a mixed complex type by a non-mixed one
being illegal. Note that no error is raised regardless of whether the
extension type explicitly sets mixed=false or relies on the default
value of the mixed attribute (false).

<?xml version="1.0" encoding="UTF-8"?>
<schema elementFormDefault='qualified'
targetNamespace='http://www.example.com/test/'
xmlns='http://www.w3.org/2001/XMLSchema'
xmlns:eg='http://www.example.com/test/'>
  <complexType name='mixedType' mixed='true'>
    <sequence>
      <any processContents='skip' minOccurs='0' maxOccurs='unbounded'
namespace='http://www.w3.org/1999/xhtml' />
    </sequence>
  </complexType>
<!-- This extension violates clause 1.4.3.2.2.1 of
http://www.w3.org/TR/xmlschema-1/#cos-ct-extends
     Xerces-J does not raise any errors or warnings when processing this
file with full schema checking
     This is still the case even with mixed=false explicitly set on the
complexType below and/or the complexContent
     Note that the inverse problem applies: move mixed=true from the
type above onto this one, and Xerces-J fails to complain
     (this case is also forbidden) -->
  <complexType name='extensionType'>
    <complexContent>
      <extension base='eg:mixedType'>
        <attribute use='required' ref='xml:lang' />
      </extension>
    </complexContent>
  </complexType>
</schema>

Is this intentional behaviour? Eclipse XSD appears to behave
identically, but we are led to believe that other tools regard such
schemas as invalid.

We are using xerces-j version 2.9.1

Thanks,

-- 
David North, Software Developer, CoreFiling Limited
http://www.corefiling.com
Phone: +44-1865-203192


Re: Extending complex types with mixed content

Posted by David North <dt...@corefiling.com>.
Hi Michael,

Thanks for the fast response. Having read through it all again, I agree
with your assesment.

Thanks,
David

On 10/03/10 12:47, Michael Glavassevich wrote:
>
> Hello David,
>
> Aside from the missing import for "xml:lang" I believe this schema is
> valid. The effective content of the extension is empty and so inherits
> the {content type} of the base which is mixed.
>
> See the definition in this section [1] of the spec:
>
> {content type}
> ...
> 3.2 If the <extension> alternative is chosen, then the appropriate
> case among the following:
> 3.2.1 If the ·effective content· is empty, then the {content type} of
> the type definition ·resolved· to by the ·actual value· of the base
> [attribute]
>
> This is a mapping from the XML representation of the complex type to
> its schema component properties. The clause [2] you've found later
> only applies to the complex type definition *component*. After mapping
> the XML representation to schema components the base and extension
> have a consistent {content type} (both being mixed) so I see no error
> here.
>
> Thanks.
>
> [1] http://www.w3.org/TR/xmlschema-1/#declare-type
> [2] http://www.w3.org/TR/xmlschema-1/#cos-ct-extends
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> David North <dt...@corefiling.co.uk> wrote on 03/10/2010
> 06:45:41 AM:
>
> > Hi,
> >
> > We think we have discovered an anomaly in Xerces' interpretation of
> > the XML schema structures specification.
> >
> > Clause 1.4.3.2.2.1 of http://www.w3.org/TR/xmlschema-1/#cos-ct-extends
> > specifies that when deriving a new complex type by extension from an
> > existing complex type, then: "Both {content type}s must be mixed or
> > both must be element-only".
> >
> > As demonstrated by the following schema, Xerces-J does not raise an
> > error despite the extension of a mixed complex type by a non-mixed
> > one being illegal. Note that no error is raised regardless of
> > whether the extension type explicitly sets mixed=false or relies on
> > the default value of the mixed attribute (false).
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <schema elementFormDefault='qualified' targetNamespace='http://
> > www.example.com/test/' xmlns='http://www.w3.org/2001/XMLSchema'
> xmlns:eg='
> > http://www.example.com/test/' <http://www.example.com/test/%27>>
> >   <complexType name='mixedType' mixed='true'>
> >     <sequence>
> >       <any processContents='skip' minOccurs='0'
> > maxOccurs='unbounded' namespace='http://www.w3.org/1999/xhtml' />
> >     </sequence>
> >   </complexType>
> > <!-- This extension violates clause 1.4.3.2.2.1 of http://
> > www.w3.org/TR/xmlschema-1/#cos-ct-extends
> >      Xerces-J does not raise any errors or warnings when processing
> > this file with full schema checking
> >      This is still the case even with mixed=false explicitly set on
> > the complexType below and/or the complexContent
> >      Note that the inverse problem applies: move mixed=true from the
> > type above onto this one, and Xerces-J fails to complain
> >      (this case is also forbidden) -->
> >   <complexType name='extensionType'>
> >     <complexContent>
> >       <extension base='eg:mixedType'>
> >         <attribute use='required' ref='xml:lang' />
> >       </extension>
> >     </complexContent>
> >   </complexType>
> > </schema>
> >
> > Is this intentional behaviour? Eclipse XSD appears to behave
> > identically, but we are led to believe that other tools regard such
> > schemas as invalid.
> >
> > We are using xerces-j version 2.9.1
> >
> > Thanks,
> > --
> > David North, Software Developer, CoreFiling Limited
> > http://www.corefiling.com
> > Phone: +44-1865-203192
>


-- 
David North, Software Developer, CoreFiling Limited
http://www.corefiling.com
Phone: +44-1865-203192


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


Re: Extending complex types with mixed content

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hello David,

Aside from the missing import for "xml:lang" I believe this schema is
valid. The effective content of the extension is empty and so inherits the
{content type} of the base which is mixed.

See the definition in this section [1] of the spec:

{content type}
...
3.2 If the <extension> alternative is chosen, then the appropriate case
among the following:
3.2.1 If the ·effective content· is empty, then the {content type} of the
type definition ·resolved· to by the ·actual value· of the base [attribute]

This is a mapping from the XML representation of the complex type to its
schema component properties. The clause [2] you've found later only applies
to the complex type definition *component*. After mapping the XML
representation to schema components the base and extension have a
consistent {content type} (both being mixed) so I see no error here.

Thanks.

[1] http://www.w3.org/TR/xmlschema-1/#declare-type
[2] http://www.w3.org/TR/xmlschema-1/#cos-ct-extends

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

David North <dt...@corefiling.co.uk> wrote on 03/10/2010 06:45:41
AM:

> Hi,
>
> We think we have discovered an anomaly in Xerces' interpretation of
> the XML schema structures specification.
>
> Clause 1.4.3.2.2.1 of http://www.w3.org/TR/xmlschema-1/#cos-ct-extends
> specifies that when deriving a new complex type by extension from an
> existing complex type, then: "Both {content type}s must be mixed or
> both must be element-only".
>
> As demonstrated by the following schema, Xerces-J does not raise an
> error despite the extension of a mixed complex type by a non-mixed
> one being illegal. Note that no error is raised regardless of
> whether the extension type explicitly sets mixed=false or relies on
> the default value of the mixed attribute (false).
>
> <?xml version="1.0" encoding="UTF-8"?>
> <schema elementFormDefault='qualified' targetNamespace='http://
> www.example.com/test/' xmlns='http://www.w3.org/2001/XMLSchema'
xmlns:eg='
> http://www.example.com/test/'>
>   <complexType name='mixedType' mixed='true'>
>     <sequence>
>       <any processContents='skip' minOccurs='0'
> maxOccurs='unbounded' namespace='http://www.w3.org/1999/xhtml' />
>     </sequence>
>   </complexType>
> <!-- This extension violates clause 1.4.3.2.2.1 of http://
> www.w3.org/TR/xmlschema-1/#cos-ct-extends
>      Xerces-J does not raise any errors or warnings when processing
> this file with full schema checking
>      This is still the case even with mixed=false explicitly set on
> the complexType below and/or the complexContent
>      Note that the inverse problem applies: move mixed=true from the
> type above onto this one, and Xerces-J fails to complain
>      (this case is also forbidden) -->
>   <complexType name='extensionType'>
>     <complexContent>
>       <extension base='eg:mixedType'>
>         <attribute use='required' ref='xml:lang' />
>       </extension>
>     </complexContent>
>   </complexType>
> </schema>
>
> Is this intentional behaviour? Eclipse XSD appears to behave
> identically, but we are led to believe that other tools regard such
> schemas as invalid.
>
> We are using xerces-j version 2.9.1
>
> Thanks,
> --
> David North, Software Developer, CoreFiling Limited
> http://www.corefiling.com
> Phone: +44-1865-203192