Lists Home |
Date Index |
Eric van der Vlist scripsit:
> I think that the additional complexity is overstated. SAX is my favorite
> XML API and I find it much more robust (and only slightly more complex)
> to never rely on the relative order of children elements. In the
> frequent case where I want to build an object out of an element, I use
> to create the object and assign the properties given as attributes on a
> start element, assign properties independently for each child element
> and do final tests and operations on end element.
But this is not true streaming: you are using SAX in order to create
your application-specific ?OM. Where you do not have the capacity or the
need to represent the document as a clump of objects, having a prescribed
ordering can be quite useful.
In one application, I have to process a stream of elements that look
<value>some human readable string</value>
Declaratively speaking, a subject has a type, a code, and a value. But by
relying on the order, I can dispatch to separate handlers depending on
the value of the type element, which can then pick up the value of the
code and (if desired) the value of the value elements. If they could
occur in any order, I would have to buffer up the (possibly long) value
element until I knew what, if anything, to do with it.
Furthermore, if I extended the value element to contain child elements
(as might be plausible for i18n purposes such as ruby or directionality),
I would have to provide a DOM-like representation of them, whereas with
my present design I can just let the code handler capture the SAX events
for the child elements directly.
> Out of context, no (sorry for that). This snippet came from a section
> giving hints to write extensible Relax NG schemas and if this is
> important for you, I think that using "interleave" is really a thing to
I agree in that case, but really because RNG has no means of doing
group-style redefinition, only choice-style and interleave-style.
(The reason for this is that if a definition were group-redefined twice,
the order of application would be unclear, since RNG definitions are
John Cowan firstname.lastname@example.org http://www.ccil.org/~cowan
Most languages are dramatically underdescribed, and at least one is
dramatically overdescribed. Still other languages are simultaneously
overdescribed and underdescribed. Welsh pertains to the third category.