[
Lists Home |
Date Index |
Thread Index
]
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
|