Re: looking for help...

I am not sure whether you received a reply to this.  Document order is 
always significant for the element  and/or character content of another 
element.  Order is never significant for attributes.  All of this is 
detailed in the XML 1 0 and Infoset recommendations, and there is no 
discretion allowed for one processor or another to change the rules.

Now,what I just said is always true of a given XML document.  I can write 
a DTD that says:

        (A|B)*

which means that the DTD will validate lots of different documents with 
A's and B's in arbitrary order.  The XML 1 0 specification still says that 
within anyone such document, the order is a significant and applications 
may take information from it.    Conversely, the recommendations say that 
regardless of what a DTD, schema, or any other description language says, 
the following two elements are identical with respect to the underlying 
information that they convey:

        <e a1="x" a2="y"/>
        <e a2="y" a1="x"/>

I hope this explanation is helpful.  Thank you very much.

------------------------------------------------------------------
Noah Mendelsohn                              Voice: 1-617-693-4036
IBM Corporation                                Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
------------------------------------------------------------------







Michael Case <mecase@ucdavis.edu>
Sent by: xmlschema-dev-request@w3.org
01/18/02 04:08 PM
Please respond to mecase

 
        To:     Eddie Robertsson <eddie@allette.com.au>
        cc:     XSD <xmlschema-dev@w3.org>
        Subject:        Re: looking for help...


Hi,

This seems to go against my conception of XML and I don't know how to
deal with it :-).  In other words, I understand that in XML,
particularly in implementations, document order is not guaranteed, am I
right?  To insist that the XML, therefore, present itself as comments
first, then Rotations, seems to fly in the face of that.

more below...

Thanks again.

Eddie Robertsson wrote:
>
> 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>

Suppose I really wanted comment elements to be interspersed anywhere
within a bunch of Rotation elements.  Would this do it?

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

Maybe I just can't extend types the way I thought I could...

>
> 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]

I do need to read more about namespaces...

>
> Hope that helps,
> /Eddie

helps a lot!!!


>
> [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

--

Michael E. Case
UC Davis
case@ucdhep.ucdavis.edu
(530) 754-7226

Received on Thursday, 24 January 2002 17:57:10 UTC