Ganymede XML Pull Parser
Jonathan Abbey <[email protected]>
| Newsgroups | gmane.text.xml.xmlpull.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, folks. I just became aware of XMLPULL through O'Reilly's XML.com site. I implemented an XML Pull Parser on top of SAX in Java a couple of years ago that appears to have many similarities to XMLPULL. I do use an XMLItem base class which I subclass for things like XMLCharData, XMLElement, XMLError, XMLStartDocument, and so forth, rather than having a single item type with a get_type() method, but it is otherwise very similar. Javadocs for my implementation can be found at http://tools.arlut.utexas.edu/gash2/doc/javadoc/arlut/csd/Util/XMLReader.html if anyone is interested in looking at it. The API is broadly similar to XMLPULL, except that I return discrete XMLItem objects, and provide a peek() method on the parser to support non-consumptive examination, rather than providing all accessor methods on the parser. This is useful in that I can use my XMLItem class and its subclasses to at any point extract a tree of descendents if necessary, rather than sticking with a pure node-by-node parse pull. In this way, I have the advantage of retrieving a DOM-like subtree at any time if that is most convenient for my code, without having to pay a full DOM price for the full document. In addition, I have a couple of minor convenience niceties which I'll mention only for personal pride, you have obviously encountered and made conscious choices about the same matters. The first is that the Ganymede XMLReader will eat adjacent open and close tags to provide a single element whose isEmpty() method will return true. I see that you provide a similar method, though I believe code using XMLPULL will still need to eat the succeeding close tag? The second is that the Ganymede XMLReader can be configured to silently consume, rather than report, any all-whitespace text blocks between elements. Finally, the Ganymede XMLReader's implementation is sort of nice, as it is a threading adaptor between SAX and the XMLReader API.. there is a circular buffer of fixed size in the XMLReader, and a background thread which runs the SAX parser and accepts SAX events into the XMLReader. If the event consumer runs ahead of the SAX parser thread, the peekNextItem() and getNextItem() methods on XMLReader will block, and if the SAX parser runs ahead of the XMLItem consumer thread, the SAX parser will block. I wonder if you are doing something similar? Anyway. I'm quite happy to see others pushing forward with pull parsers.. it seems crazy to have to use either a low-level SAX type interface for anything significant, and it seems crazy to have to pay a full DOM price for large documents. Best of luck with XMLPULL. jon -- ------------------------------------------------------------------------------- Jonathan Abbey [email protected] Applied Research Laboratories The University of Texas at Austin Ganymede, a GPL'ed metadirectory for UNIX http://www.arlut.utexas.edu/gash2 ------------------------ Yahoo! Groups Sponsor ---------------------~--> Get 128 Bit SSL Encryption! http://us.click.yahoo.com/JjlUgA/vN2EAA/kG8FAA/2U_rlB/TM ---------------------------------------------------------------------~-> To unsubscribe from this group, send an email to: [email protected] Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/