Re: looking for help...

Hi Michael,

> 1)  When you extend a type, is there anything that says the ORDER of the
> internal elements is implied?  I may not understand enough to ask it
> properly.

After looking at your example below I think I know what your problem is. When you extend a type in
XML Schema it is important to know that the extended types content model will be the base types
particle sequenced together with the particle defined by the child of the extension element. This
means that when you extend a sequence group with another element then you're not actually extending
the base sequence with another element. I use your example to illustrate:
In your base type you have:

<xsd:sequence>
    <xsd:element name = "comment" type = "xsd:string" minOccurs = "0" maxOccurs = "unbounded"/>
</xsd:sequence>

And then your extended type look like:

<xsd:complexType name = "RotationSectionType">
    <xsd:complexContent>
          <xsd:extension base = "SectionType">
              <xsd:sequence>
                  <xsd:element ref = "Rotation" minOccurs = "0" maxOccurs ="unbounded"/>
              </xsd:sequence>
         </xsd:extension>
    </xsd:complexContent>
</xsd:complexType>

When the processor expands this new extended type it will in fact sequence together the two content
models and create the following type:

<xsd:complexType name = "RotationSectionType">
    <xsd:sequence>
        <xsd:sequence>
             <xsd:element name = "comment" type = "xsd:string" minOccurs = "0" maxOccurs =
"unbounded"/>
        </xsd:sequence>
        <xsd:sequence>
            <xsd:element ref = "Rotation" minOccurs = "0" maxOccurs ="unbounded"/>
        </xsd:sequence>
    </xsd:sequence>
</xsd:complexType>

As you can see this is the cause of your error. In your instance you have:

       <RotationSection label = "blah">
                <comment xmlns = ""/>
               <Rotation name = "chfghfhf" theta1 = "0" phi1 = "0" theta2 = "0" phi2 = "0" theta3 =
"0" phi3 = "0"/>
                <comment xmlns = ""/>
                <comment xmlns = ""/>
        </RotationSection>

but this is not valid since all comment elements (if any are present) need to appear before the
Rotation elements.

> 2)  Why does comment want xmlns=""???

This is because you have elementFormDefault="unqualified" in your schema. In short, what this means
is that all elements that you have declared locally (nested within complexTypes or groups) cannot be
qualified with a namespace in the instance document. Since you're using the default namespace
declaration (xmlns = "http://www.cern.ch/cms/DDL") in the instance this means that all elements
without a prefix will be qualified by this namespace. However, the processor expects the comment
element to be unqualified and hence you get an error. There are two solutions to your problem:

1) add xmlns="" to the comment elements (What you have)
2) Change the value of elementFormDefault to "qualified"

To read more about namespaces see [1]

Hope that helps,
/Eddie

[1] http://www.w3.org/TR/xmlschema-0/#NS

> Somehow, I think I just don't understand the right way to do things :-).
>
> Thanks for any help.
>
> -------------------------
> A subset of our Schema is below.  It doesn't do what I want.  It fails
> in the following way both with TIBCO's TurboXML and with SAX2Count from
> xerces-c1_6_0-linux.
>
> 1) (above) The error in TurboXML is:
>
> Element "RotationSection": expected Rotation
>
> And with SAX2Count I get:
>
> Error at file
> /home/mec/Projects/DetectorDescription/G3Convert_0_1_1/DDLSchema/DDLTestRotationInstance.xml,
> line 8, char 20
>   Message: Element 'comment' is not valid for content model:
> '(comment*,Rotation*)'
>
> Which happen when comment elements come after Rotation elements inside a
> RotationSection... (example below).
>
> 2) (above) The error in TurboXML is:
>
> Element "RotationSection": expected Rotation or comment (with no
> namespaces)
>
> SAX2Count I get:
>
> Error at file
> /home/mec/Projects/DetectorDescription/G3Convert_0_1_1/DDLSchema/DDLTestRotationInstance.xml,
> line 6, char 12
>   Message: Element 'comment' should be un-qualified
>
> =============== XML Schema =====================
>
> <?xml version = "1.0" encoding = "UTF-8"?>
> <!--Generated by XML Authority. Conforms to w3c
> http://www.w3.org/2001/XMLSchema-->
> <xsd:schema xmlns = "http://www.cern.ch/cms/DDL"
>          targetNamespace = "http://www.cern.ch/cms/DDL"
>          xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
>          elementFormDefault = "unqualified"
>          attributeFormDefault = "unqualified">
>
>         <xsd:element name = "DDDefinition" type = "DDDefinitionType"/>
>         <xsd:complexType name = "DDDefinitionType">
>                 <xsd:sequence>
>                         <xsd:element ref = "Section" minOccurs = "0" maxOccurs =
> "unbounded"/>
>                 </xsd:sequence>
>         </xsd:complexType>
>
>         <xsd:element name = "Section" type = "SectionType" abstract = "true"/>
>         <xsd:element name = "RotationSection" type = "RotationSectionType"
> substitutionGroup = "Section"/>
>         <xsd:complexType name = "SectionType">
>                 <xsd:sequence>
>                         <xsd:element name = "comment" type = "xsd:string" minOccurs = "0"
> maxOccurs = "unbounded"/>
>                 </xsd:sequence>
>                 <xsd:attributeGroup ref = "SectionAttributes"/>
>         </xsd:complexType>
>         <xsd:attributeGroup name = "SectionAttributes">
>                 <xsd:attribute name = "label" use = "optional" type = "xsd:string"/>
>         </xsd:attributeGroup>
>
>         <xsd:complexType name = "RotationSectionType">
>                 <xsd:complexContent>
>                         <xsd:extension base = "SectionType">
>                                 <xsd:sequence>
>                                         <xsd:element ref = "Rotation" minOccurs = "0" maxOccurs =
> "unbounded"/>
>                                 </xsd:sequence>
>                         </xsd:extension>
>                 </xsd:complexContent>
>         </xsd:complexType>
>
>         <xsd:element name = "Rotation" type = "RotationType"/>
>         <xsd:complexType name = "RotationType">
>                 <xsd:attributeGroup ref = "RotationAttributes"/>
>         </xsd:complexType>
>         <xsd:attributeGroup name = "RotationAttributes">
>                 <xsd:attribute name = "name" use = "required" type = "xsd:string"/>
>                 <xsd:attribute name = "theta1" use = "required" type = "xsd:float"/>
>                 <xsd:attribute name = "phi1" use = "required" type = "xsd:float"/>
>                 <xsd:attribute name = "theta2" use = "required" type = "xsd:float"/>
>                 <xsd:attribute name = "phi2" use = "required" type = "xsd:float"/>
>                 <xsd:attribute name = "theta3" use = "required" type = "xsd:float"/>
>                 <xsd:attribute name = "phi3" use = "required" type = "xsd:float"/>
>                 <xsd:attribute name = "angleUnit" use = "optional" type =
> "xsd:float"/>
>         </xsd:attributeGroup>
> </xsd:schema>
>
> ========================= Instance example ===========================
>
> <?xml version = "1.0" encoding = "UTF-8"?>
> <DDDefinition xmlns = "http://www.cern.ch/cms/DDL" xmlns:xsi =
> "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation =
> "http://www.cern.ch/cms/DDL
> file:///home/mec/Projects/DetectorDescription/G3Convert_0_1_1/DDLSchema/DDLTestRotation.xsd">
>         <RotationSection label = "blah">
>                 <comment xmlns = ""/>
>                 <Rotation name = "chfghfhf" theta1 = "0" phi1 = "0" theta2 = "0" phi2
> = "0" theta3 = "0" phi3 = "0"/>
>                 <comment xmlns = ""/>
>                 <comment xmlns = ""/>
>         </RotationSection>
> </DDDefinition>
>
> --
>
> Michael E. Case
> UC Davis
> case@ucdhep.ucdavis.edu
> (530) 754-7226

Received on Wednesday, 16 January 2002 20:17:24 UTC