Re: [xml] export DOM tree with SAX interface



On Fri, Mar 29, 2002 at 04:51:36PM +0100, Fernand Albarracin wrote:
Hi Daniel, hi libxml people,

I need a special feature that I believe is not present in libxml right
now. Searching in the list archive, I found the following post under the
subject "[xml] libxml2/sax/write-back" (2002/02/06) :
[..]
  Well, no there isn't any "inverted SAX" which would reserialize
a stream of event, it's somewhere deep in the TODO list. It's relatively
simple but I didn't had the time to do this.

Daniel

I guess you were refering to the following entry of the TODO file :

# - jamesh suggestion: SAX like functions to save a document ie. call a
#   function to open a new element with given attributes, write character
#   data, close last element, etc

  Right,

I need something similar. Then, as I understand libxml, there are two
ways to achieve this :

A. xmlDocDumpMemory() + xmlSAXUserParseMemory()

  Hum, braindead, sorry :-)

B. traverse the tree with functions similar to
xmlDocContentDumpOutput(), xmlNodeDumpOutput() and
xmlNodeListDumpOutput() but instead of writing to a xmlOutputBuffer,
these would call user-supplied callbacks (from a xmlSAXHandler)

Right ?

  Right

Obviously A is not efficient. Worse : it's not The Right Thing (tm).  :)

  Clearly not the right thing.

Is there a better approach ?

  No it's how I would do myself. It should not be very difficult
look at the existing serialization code and replace all the routines
to save to the buffer by their SAX counterpart.

I haven't done any serious work with
libxml, am I missing some really important aspects of its achitecture ?

  No, it sounds right,

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]