W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2007

Re: Attributes ordering

From: <noah_mendelsohn@us.ibm.com>
Date: Thu, 22 Mar 2007 15:34:16 -0300
To: Nataraj Ramalingam <Nataraj.Ramalingam@aricent.com>
Cc: gkholman@CraneSoftwrights.com, xmlschema-dev@w3.org, xmlschema-dev-request@w3.org
Message-ID: <OFEAABE9BC.D41624F0-ON842572A6.0065C9A3-842572A6.006607E8@lotus.com>

Sequence means what it says, I.e. in order.  The type you give will 
validate <a/> <b/> <c/> or <a/> <c/>.  It will not validate <a/> <c/> 
<b/>.  To get that, you'd need another reference to an optional "b" after 
the reference to "c", or else maybe a wildcard (<xsd:any>).  Have you 
looked at the Schema Primer [0]?   It explains many of these things. 
Otherwise, you might find some good tutorials on the Web, or look for 
books like Priscilla Walmsley's.  These are fairly basic concepts and I 
think they're well covered in lots of the tutorial material that's out 
there.

Noah

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

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








Nataraj Ramalingam <Nataraj.Ramalingam@aricent.com>
Sent by: xmlschema-dev-request@w3.org
03/22/2007 02:42 AM
 
        To:     noah_mendelsohn@us.ibm.com
        cc:     gkholman@CraneSoftwrights.com, xmlschema-dev@w3.org
        Subject:        Re: Attributes ordering



Hi Noah, 

Thanks for your answer. I have one more doubt w.r.t ordering of elements. 
consider the following example. 
===================================================== 
<xs:complexType name="test"> 
        <xs:sequence> 
                <xs:element name="a" type="xs:string"/> 
                <xs:element name="b" type="xs:string" minOccurs="0"/> 
                <xs:element name="c" type="xs:string"/> 
        </xs:sequence> 
</xs:complexType> 

<xs:element name="test" type="test"/> 
===================================================== 

Eventhough we use a sequence type here, does this mandate the order of 
elements in the instance to be only a,b,c. 
Or, since "b" is optional ( minOccurs=0 ), can it (should it, by any means 
)come after "c" in the instance? for example, can the ordering be a,c,b? 


Kind Regards, 
Nataraj. 




noah_mendelsohn@us.ibm.com 
Sent by: xmlschema-dev-request@w3.org 
03/21/2007 03:12 AM 


To
Nataraj Ramalingam/CHE/HSS@HSS 
cc
"G. Ken Holman" <gkholman@CraneSoftwrights.com>, xmlschema-dev@w3.org 
Subject
Re: Attributes ordering









Nataraj Ramalingam writes:

> So, this confirms that attributes can appear in any order in an 
> element instance. 

The short and simple answer is "yes".  For almost all practical purposes, 
the order of attributes is insignificant, as are some other details like 
whether you choose to use single or double quotes around attribute values.

Having given the simple answer, let me signal where exceptions can be 
found.  Some tools do work with XML at a lower level.  For example, some 
(not all) XML editors try to preserve the look of an XML document so that 
human readers can have an easy time.  So, for such tools, the order and 
even the layout of the attributes may be considered significant. 
Furthermore, XML is in the end text, and if you choose to use text tools 
on it, then things XML considers insignificant may matter.  A classic 
example is using source control systems to manage XML documents.  It's 
very typical to find arguments when XML projects start up about whether 
its OK for an XML editor to change attribute quotes from single to double, 

because many editors don't want to track what kind of quoting was used. 
>From an XML perspective, such changes are just fine, but it can lead CVS 
to conclude that 90% of your file has changed when in fact nothing 
important was touched.

Bottom line, attribute order mostly doesn't matter.

Noah

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








Nataraj Ramalingam <Nataraj.Ramalingam@aricent.com>
Sent by: xmlschema-dev-request@w3.org
03/19/2007 01:47 AM

       To:     "G. Ken Holman" <gkholman@CraneSoftwrights.com>
       cc:     xmlschema-dev@w3.org, (bcc: Noah Mendelsohn/Cambridge/IBM)
       Subject:        Re: Attributes ordering



Thanks Ken. 

So, this confirms that attributes can appear in any order in an element 
instance. 

Kind Regards, 
Nataraj. 


xmlschema-dev-request@w3.org wrote on 03/19/2007 03:10:52 AM:

> 
> At 2007-03-17 17:26 +0530, Nataraj Ramalingam wrote:
> >I am little new to XML. I have a basic doubt in the ordering of 
> >attributes inside a complex type.
> >...
> >I know that the elements ordering can be controlled using "sequence" 
> >or "all". But i am not sure about the same behavior with attributes.
> 
> Note that XML 1.0 fourth edition (and all editions) states in section 
3.1:
> 
>    http://www.w3.org/TR/2006/REC-xml-20060816/#sec-starttags
>    Note that the order of attribute specifications in a start-tag
>    or empty-element tag is not significant.
> 
> I hope this helps.
> 
> . . . . . . . . . . . . Ken
> 
> 
> --
> World-wide corporate, govt. & user group XML, XSL and UBL training
> RSS feeds:     publicly-available developer resources and training
> G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
> Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
> Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
> Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/x/bc
> Legal business disclaimers:  http://www.CraneSoftwrights.com/legal
> 
> 





***********************  Aricent-Private   *********************** 
"DISCLAIMER: This message is proprietary to Aricent and is intended solely 
for the use of 
the individual to whom it is addressed. It may contain privileged or 
confidential information and should not be 
circulated or used for any purpose other than for what it is intended. If 
you have received this message in error, 
please notify the originator immediately. If you are not the intended 
recipient, you are notified that you are strictly
prohibited from using, copying, altering, or disclosing the contents of 
this message. Aricent accepts no responsibility for 
loss or damage arising from the use of the information transmitted by this 
email including damage from virus."
Received on Thursday, 22 March 2007 18:34:36 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:41 UTC