OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   The order of attributes

[ Lists Home | Date Index | Thread Index ]
  • To: xml-dev@lists.xml.org
  • Subject: The order of attributes
  • From: Xasima Xirohata <xasima@gmail.com>
  • Date: Fri, 6 Jan 2006 11:29:30 +0200
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=Ebsz9awjKMlWqIozMxZrgoG3RsqKYkdJ5BluMrfo3aZ6iv9y/Ls6t77N4iKiHkJ8zGIj6m+PNsV3a+swQ3yOSBcFYDFs//rAJeqLqoJ51NLKqY5NY9DOjnNtyRXTY2JQd8gwlDr533g3sU5TxFLe2Bns+AlwYPMKtwhXFs+WPrM=

Hi, everybody.

I wonder why the order of attributes doesn't matter in the XML 1.0.  spec.

I've tried to find the reason for the fact, so I believe that there is the only situation that might deal with this. A mixed content is commonly used in xml elements, while it's impossible to imagine something like "mixed" in the scope of attributes. If the mixed content would unhappily be forbidden in the scope of element, the order of elements hadn't been of importance too. If something like mixed content would be allowed in the scope of attributes, the order of attributes had been of importance.


On the other hand, while we are trying to express some kind of information relations of the document by the XML notation, I don't consider strange the idea of using the order of attributes in some purposes.

For example, we have the xml document that express what font should be used for the text. If some font isn't found at the target system, the next font in the sequence should be used.

Xml:
<text>
  <font_sequence>
    <font>Antique Olive</font>
    <font>Franklin Gothic Book</font>
    <font>Arial</font>
  </font_sequence >
  <content>
     Once upon a time ...
  </content>
</text>


It is endurable to rewrite it like this
<text font1="Antique Olive"
      font2="Franklin Gothic Book"
      font3="Arial">
     Once upon a time ...
</text>


You see that XML spec say you should explicitly control the names of the attributes. Due to the absence of attribute ordering, you couldn't write in the following way

foreach ( attr in  "/text/@*" ){
      if (exist_in_system(attr))
         break;
}
I agree that this rule is valuable and merited. I'd only like to know why it emerges.

The next questions that might possible been discussed a long ago is the uniqueness of names of attributes. I accept that some of attributes must be unique in the element scope (i.e., "id" attribute). I wonder whether the name uniqueness is the semantic requirement to do well design, or it's only the relieving for parser processing (it had been too difficult exploring elements by the attribute keys if there would be the necessity to set the primary key for each XML documents).
What's strange in sense in the following xml.
<text author="George "
      author="Mike"
      author="Alexander">
     Once upon a time ...
</text>



Present my apologies of asking the strange and well-known questions.


--
Regards,
          ~ Xasima Xirohata ~



 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS