Hi

I have just started to evaluate the XML Schema Model of Castor 0.9.9.
In the past I have implemented an XML schema processor using C++.
During that time I did a lot of reading in the XML schema recommendation.
Meanwhile, I'm looking for a schema model implemented in Java. 

When looking more closely at the schema model created by the SchemaReader, 
I found some results which look like inconsistencies with the XML schema spec.
If I did not miss something, they might deserve to be fixed 
before the final release.

Before going into details:
(1) seems to be a severe bug in conjunction with schema composition 
    and namespace handling and there is no simple workaround
(2) seems to be a severe bug when using a hierarchy of complex types 
    with attributes
(3) deals with a very special and probably even exotic case 

At least for fixing (1) some modifications in 
org.exolab.castor.xml.schema.Schema
are required - maybe I could assist on that.

Best regards
Uli

(1) Namespace handling
    ===================
    Various unqualified references to named global objects without a namespace 
    are not resolved correctly. This affects usage of the following attributes
    which have a type QName as of the Schema for Schemas:
    - ref (used in attribute, element, group, attributeGroup)
    - type (used in attribute, element)
    - base (used in restriction, extension)
    - substitutionGroup (used in element)
    - itemType (used in list)

    So far, I have not tested all these scenarios, only the following
    - <xs:element ref="...">
    - <xs:attribute ref="...">
    - <xs:attribute ... type="...">
    - <xs:attributeGroup ref="...">
    - <xs:group ref="...">

    The following example illustrates the bug for <xs:attribute ref="...">:

withTNS.xsd
    <xs:schema targetNamespace="NS1" 
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
      <xs:import schemaLocation="./noTNS.xsd"/>

      <xs:attribute name="A1" type="xs:date"/>

      <xs:element name="E1">
        <xs:complexType>
          <xs:attribute ref="A1"/>
        </xs:complexType>
      </xs:element>
    </xs:schema>

noTNS.xsd:
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
      <xs:attribute name="A1" type="xs:time"/>
    </xs:schema>

As there is no namespace declaration for the default namespace in withTNS.xsd,
the QName value of the ref attribute in <xs:attribute ref="A1"/> is {-,A1},
i.e. without any URI. Hence, it should resolve to attribute A1 as declared in 
noTNS.xsd. Unfortunately, when calling attrDecl.getReference() for the attrDecl
constructed from <xs:attribute ref="A1"/>, the global attribute declaration for
A1 in withTNS.xsd is returned.

When looking for a respective bug report I occasionally found a schema at
http://jira.codehaus.org/browse/CASTOR-1105 which is accepted by Castor, but
should not:
- references like type="string" are not valid if
  (a) there is no default namespace declaration 
        xmlns="http://www.w3.org/2001/XMLSchema";
  and
  (b) there is no user-defined type named "string" being defined in a schema
      without a targetNamespace


(2) Attribute Declarations and attribute wildcards inherited from base type
    =======================================================================

Look at the following schema fragment:

  <xs:complexType name="C1">
    <xs:sequence>
      <xs:element name="E1-C1" minOccurs="0" maxOccurs="27"/>
    </xs:sequence>
    <xs:attribute name="A1-C1" type="xs:float"/>
  </xs:complexType>

  <xs:complexType name="C2">
    <xs:complexContent>
      <xs:extension base="C1">
        <xs:choice>
          <xs:element name="E1-C2"/>
        </xs:choice>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="C3">
    <xs:complexContent>
      <xs:restriction base="C1">
        <xs:sequence>
          <xs:element name="E1-C1" minOccurs="0" maxOccurs="1"/>
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  The following should show up in the schema model:
  (a) Both derived complexTypes, C2 and C3 should have an attribute use with 
name "A1-C1"
      Castor does not return that!
      See "3.4.2 XML Representation of Complex Type Definitions" 
      (http://www.w3.org/TR/xmlschema-1/#declare-type) 
      e.g. under "Complex Type Definition with simple content Schema Component"
      you'll find

      <cite>
      {attribute uses} 
      A _union_ of sets of attribute uses as follows 
      ...
      3 if the type definition ·resolved· to by the ·actual value· of the 
        base [attribute] is a complex type definition, the {attribute uses} 
        of that type definition, unless the <restriction> alternative is 
chosen, 
        in which case some members of that type definition's {attribute uses} 
        may not be included, ...
      </cite>

      In a similar way, an attribute wildcard is propagated to the properties
      of the derived type.

  (b) C2 should have an _effective_ content model which is a sequence 
      containing two particles:
      - the first one is the sequence as defined in "C1", 
      - the second is the choice as defined in "C2"

        "Complex Type Definition with complex content Schema Component"

(3) Restricting an complexType with complexContent to complexType with 
simpleContent
    
================================================================================

    - see "Schema Component Constraint: Derivation Valid (Restriction, Complex)"
      (http://www.w3.org/TR/xmlschema-1/#derivation-ok-restriction)
        5.2.2.2 The {content type} of the {base type definition} must be 
elementOnly
              or mixed and have a particle which is ·emptiable· as defined in 
              Particle Emptiable (§3.9.6). 

    The following schema meets these constraints:

        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
          <xs:complexType name="CT1" mixed="true">
            <xs:sequence>
                <xs:element name="E1-CT1" minOccurs="0" maxOccurs="1"/>
            </xs:sequence>
        </xs:complexType>
                
          <xs:complexType name="CT2">
            <xs:simpleContent>
                <xs:restriction base="CT1">
                  <xs:simpleType>
                    <xs:restriction base="xs:int"/>
                  </xs:simpleType>
                </xs:restriction>
            </xs:simpleContent>
          </xs:complexType>
                
        </xs:schema>

but is rejected by Castor with the following exception:

complexType: CT2In a simpleContent when using restriction the base type must be 
a complexType whose base is a simpleType.
        at 
org.exolab.castor.xml.schema.reader.ComponentReader.error(ComponentReader.java:213)
        at 
org.exolab.castor.xml.schema.reader.SchemaUnmarshaller.startElement(SchemaUnmarshaller.java:470)
        at 
org.exolab.castor.xml.schema.reader.Sax2ComponentReader.startElement(Sax2ComponentReader.java:253)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown 
Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown 
Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
 Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)
...

-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to