[
Lists Home |
Date Index |
Thread Index
]
- To: xml-dev@lists.xml.org
- Subject: XML newbie question: processing order of XML elements
- From: "Ralf M." <ralfml@alfray.com>
- Date: Sat, 13 Dec 2003 15:22:57 -0800
- Organization: Beatware Inc.
- User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624
Hi!
I have an XML newbie question regarding processing order of XML
elements, I believe also called sequencing vs non-sequencing in XML.
Background: Until recently, I was told multiple times that element order
should not matter in XML, whereas I always believed it should.
Well actually I always believed it should be meta semantic associated
with the XML which was not expressed by the DTD nor the Schema (I still
have a rather limited understanding of those, sorry). Reading the XML
spec 1.0 again I find out that:
- Element content (http://www.w3.org/TR/REC-xml#sec-element-content)
nodes contain other elements have an implicity ordering. The DTD
described the grammar (choices, sequences, mixed).
- Mixed element (http://www.w3.org/TR/REC-xml#sec-mixed-content) nodes
can contain both character data and child elements. In this case the DTD
can constraint the type of the child elements but not their order nor
their number.
I fail to see why the mixed elements could not constraint that, but
that's not my question here.
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>...).
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, 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. I'd like to avoid
having to parse a DTD or a Schema if any.
Comments, bashing or references appreciated.
R/
|