XML. SAX. Streaming processing with Groves.
paul at qub.com
Fri Dec 3 05:08:13 GMT 1999
The advantage of SAX ( and attributes in XML)
is that we have attributes in place when startElement
is invoked. We know what are some properties of this
element right when element begins.
At that point could we get the information about
the another properties this element has
( the child elements ) ?
No. We can not. If we'l decide to read the entire
element before infoking startElement() - we'l have
to read the entire ( root ) document to know.
DOM does it.
How can we workaround this limitation?
Right now I'm writing yet another wrapper
around SAX, accumulating the element contents
in 'microDOM' and then making a descision in
endElement() what to do with the element
itself depending on the values of his children.
The 'correct' approach to avoid such a hell
is to use DOM - but I can't. Documents could
I also can not require the client to turn all their
elements into attributes.
It's actualy very interesting. If one wants his
XML documents to be easy to process
without DOM he should have as much attributes
as it's possible !
Isn't it the end of long discussion of Elements vs Attributes?
Now when I see the question: "Should I use attributes or
elements?" - I know the answer:
"If you want it to be processed by current APIs not keeping
the entire docuemnt in the memory - use attributes everywhere
What if for *some* elements parser would invoke
startElement ( or endElement) *after* reading the
entire element and placing all the children into ... Grove) ?
I think I could specify those 'return-as-grove' elements
at runtime, or when I'm initializing the parser.
How easy is to it do with curent SAX design ?
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at ic.ac.uk the following message;
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
More information about the Xml-dev