You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Rich Adili <Ri...@xata.com> on 2007/05/18 05:23:56 UTC

XML Schema Element ordering

This xml will not validate against the enclosed schema unless I reorder
the four text elements to match. How can I adjust the schema to allow
mix-and-match ordering of the elements without breaking the "Upper" and
"Lower" set relationships? I've heard the lecture that node order
shouldn't matter in XML but my boss is funny about giving orders and
having them followed...

<?xml version="1.0" encoding="UTF-8"?>
<Upper xsi:noNamespaceSchemaLocation="junk.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<ValidationError>text</ValidationError>
	<WildAndCrazy>text</WildAndCrazy>
	<ValidationWarning>text</ValidationWarning>
	<Guy>text</Guy>
</Upper>

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xsd:complexType name="Lower" abstract="true">
		<xsd:sequence minOccurs="0" maxOccurs="unbounded">
			<xsd:element ref="ValidationError"
minOccurs="0"/>
			<xsd:element ref="ValidationWarning"
minOccurs="0"/>
		</xsd:sequence>
	</xsd:complexType>
	<xsd:element name="ValidationError"/>
	<xsd:element name="ValidationWarning"/>
	<xsd:element name="Upper">
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="Lower">
					<xsd:sequence minOccurs="0"
maxOccurs="unbounded">
						<xsd:element
ref="WildAndCrazy" minOccurs="0"/>
						<xsd:element ref="Guy"
minOccurs="0"/>
					</xsd:sequence>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="WildAndCrazy"/>
	<xsd:element name="Guy"/>
</xsd:schema>

RE: XML Schema Element ordering

Posted by Rich Adili <Ri...@xata.com>.
Thanks for the pointer, I was wondering!

-----Original Message-----
From: Michael Glavassevich [mailto:mrglavas@ca.ibm.com] 
Sent: Thursday, May 17, 2007 11:03 PM
To: general@xerces.apache.org
Subject: Re: XML Schema Element ordering

Hi,

Your question doesn't appear to have anything to do with Xerces. For 
generic usage queries about XML Schema, the W3C mailing list [1] is more

appropriate.

Thanks.

[1] http://lists.w3.org/Archives/Public/xmlschema-dev/

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

"Rich Adili" <Ri...@xata.com> wrote on 05/17/2007 11:23:56 PM:

> This xml will not validate against the enclosed schema unless I 
> reorder the four text elements to match. How can I adjust the schema
> to allow mix-and-match ordering of the elements without breaking the
> ?Upper? and ?Lower? set relationships? I?ve heard the lecture that 
> node order shouldn?t matter in XML but my boss is funny about giving
> orders and having them followed?
> <?xml version="1.0" encoding="UTF-8"?>
> <Upper xsi:noNamespaceSchemaLocation="junk.xsd" xmlns:xsi="http:
> //www.w3.org/2001/XMLSchema-instance">
>         <ValidationError>text</ValidationError>
>         <WildAndCrazy>text</WildAndCrazy>
>         <ValidationWarning>text</ValidationWarning>
>         <Guy>text</Guy>
> </Upper>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="
> qualified" attributeFormDefault="unqualified">
>         <xsd:complexType name="Lower" abstract="true">
>                 <xsd:sequence minOccurs="0" maxOccurs="unbounded">
>                         <xsd:element ref="ValidationError" 
minOccurs="0"/>
>                         <xsd:element ref="ValidationWarning" 
minOccurs="0"/>
>                 </xsd:sequence>
>         </xsd:complexType>
>         <xsd:element name="ValidationError"/>
>         <xsd:element name="ValidationWarning"/>
>         <xsd:element name="Upper">
>                 <xsd:complexType>
>                         <xsd:complexContent>
>                                 <xsd:extension base="Lower">
>                                         <xsd:sequence minOccurs="0" 
maxOccurs
> ="unbounded">
>                                                 <xsd:element 
ref="WildAndCrazy
> " minOccurs="0"/>
>                                                 <xsd:element ref="Guy"
> minOccurs="0"/>
>                                         </xsd:sequence>
>                                 </xsd:extension>
>                         </xsd:complexContent>
>                 </xsd:complexType>
>         </xsd:element>
>         <xsd:element name="WildAndCrazy"/>
>         <xsd:element name="Guy"/>
> </xsd:schema>


Re: XML Schema Element ordering

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

Your question doesn't appear to have anything to do with Xerces. For 
generic usage queries about XML Schema, the W3C mailing list [1] is more 
appropriate.

Thanks.

[1] http://lists.w3.org/Archives/Public/xmlschema-dev/

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

"Rich Adili" <Ri...@xata.com> wrote on 05/17/2007 11:23:56 PM:

> This xml will not validate against the enclosed schema unless I 
> reorder the four text elements to match. How can I adjust the schema
> to allow mix-and-match ordering of the elements without breaking the
> ?Upper? and ?Lower? set relationships? I?ve heard the lecture that 
> node order shouldn?t matter in XML but my boss is funny about giving
> orders and having them followed?
> <?xml version="1.0" encoding="UTF-8"?>
> <Upper xsi:noNamespaceSchemaLocation="junk.xsd" xmlns:xsi="http:
> //www.w3.org/2001/XMLSchema-instance">
>         <ValidationError>text</ValidationError>
>         <WildAndCrazy>text</WildAndCrazy>
>         <ValidationWarning>text</ValidationWarning>
>         <Guy>text</Guy>
> </Upper>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="
> qualified" attributeFormDefault="unqualified">
>         <xsd:complexType name="Lower" abstract="true">
>                 <xsd:sequence minOccurs="0" maxOccurs="unbounded">
>                         <xsd:element ref="ValidationError" 
minOccurs="0"/>
>                         <xsd:element ref="ValidationWarning" 
minOccurs="0"/>
>                 </xsd:sequence>
>         </xsd:complexType>
>         <xsd:element name="ValidationError"/>
>         <xsd:element name="ValidationWarning"/>
>         <xsd:element name="Upper">
>                 <xsd:complexType>
>                         <xsd:complexContent>
>                                 <xsd:extension base="Lower">
>                                         <xsd:sequence minOccurs="0" 
maxOccurs
> ="unbounded">
>                                                 <xsd:element 
ref="WildAndCrazy
> " minOccurs="0"/>
>                                                 <xsd:element ref="Guy"
> minOccurs="0"/>
>                                         </xsd:sequence>
>                                 </xsd:extension>
>                         </xsd:complexContent>
>                 </xsd:complexType>
>         </xsd:element>
>         <xsd:element name="WildAndCrazy"/>
>         <xsd:element name="Guy"/>
> </xsd:schema>