Re: [xml] how to advance the xmlParserInput.cur?





On Sun, 12 Mar 2006, Daniel Veillard wrote:

On Sat, Mar 11, 2006 at 11:00:01PM -0500, Wei Lu wrote:

Hi there
    I have a strang requirement for libxml2. During parsing a XML
document in the memory at some point I want to the parser to skip parsing
a chunk of memory, which is somehow guarnteed to just include a
well-balanced sub-tree. I modified the xmlParseContent function to skip a
chunk of memory when it detected a open tag. Any body can tell me the
correct and safe method to do that.

  By definition it's not correct, it's not an XML parser anymore, "somehow
it's XML" is not something I feel okay to provide help for. What do you intend
to do with this bastardized code ?

The ability of skipping of a sub tree is useful for some perfomrance
optimization. For example lazy evaluation can skip a sub-tree once it
found user are not interested in the sub-tree. For tree
   A
  / \
 B   C, if B is not used now, then the generated tree could be just

   A
    \
     C

Thanks
Wei



By guess I tried the
xmlParserInputGrow, which seems doesn't change the xmpParserInput.cur at
all; Now my work around is just increaing the xmlParserInput.cur directly,
seems works well, but when file size is large, I got segment fault.

Any clue is appreciated.

  You will need to refill the buffers if you get outside of the chunk
already availble in xmpParserInput. It is *not* trivial, encoding will
play a role too.

Daniel

--
Daniel Veillard      | Red Hat http://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]