[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XML newbie question: processing order of XML elements

  • To: xml-dev@l...
  • Subject: Re: XML newbie question: processing order of XML elements
  • From: "Thomas B. Passin" <tpassin@c...>
  • Date: Sat, 13 Dec 2003 21:16:39 -0500
  • In-reply-to: <3FDB9F51.5080703@a...>
  • References: <3FDB9F51.5080703@a...>
  • User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4

xml order of elements
Ralf M. wrote:

> I don't feel that the spec clearly precise what the user of the XML 
> should do. Is it ok to process child nodes of a mixed element in 
> arbitrary order? In real life, I do not think that would be wise (f.ex. 
> <font> tags in an HTML <p>...).
> 

It depends on whether you are going to use a processor, like a SAX 
parser, that sends you a serial stream of document events, or whether 
your processor builds you a DOM or some other object model.  If the 
latter, it is up to you to do whatever you want with the nesting and 
ordering of the elements (which have now become objects).

But I imagine you are talking about SAX-like processing.  The order of 
elements in an xml document _is_ considered significant.  It is the 
order of _attributes_ that is not.  Normal processors will maintain 
document order for elements but not necessarily for attributes.

> So when I design my XML, should I expect all the target applications 
> (especially the one I can't control) to process all the non-mixed 
> elements in order, 

Yes, and the mixed content elements too. E.g., "<p>This <i>is</i> a 
<b>test</b></p>" will not come out scrambled. Be aware, thouogh, that 
you might get character content within an element in more than one piece 
- at least with SAX, you have to make sure to collect all of such pieces.

> or should I provide some kind of mechanism to 
> identify the order (I noticed RDF/XML has this rdf:seq in RSS 1.0, which 
> looks redundant if element order is expected to be respected).
> In my case I need to load some custom XML, process it (actually perform 
> a simplistic diff on elements) and write it back. I'd like to know if 
> generally speaking the ordering of elements should be retained or if the 
> processing can reorder them as is most convenient.

_Your_ processing can do whatever you feel like, but you will be 
receiving elements in document order.

Cheers,

Tom P


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.