Re: [xml] xinclude and xmlParseChunk



* Daniel Veillard <veillard redhat com> [2011-03-03 00:42] writes:
On Wed, Mar 02, 2011 at 09:00:12PM +0000, Lucian Smith wrote:
* Daniel Veillard <veillard redhat com> [2011-03-02 06:31] writes:
On Tue, Mar 01, 2011 at 10:14:30PM +0000, Lucian Smith wrote:
Hello, all.  I am investigating how to modify a system that currently uses 
libxml, with its core parsing done by calling the function 
'xmlParseChunk'.

I would like to expand the capabilities of the system to allow it to 
expand xinclude directives.  However, all the ways I have discovered to do 
this seem to be incompatible with only using xmlParseChunk--the 
'xmlCtxtUseOptions' function does not even check the XML_PARSE_XINCLUDE 
flag.

Is there any way to access xinclude auto-expansion within 'xmlParseChunk'?  
Or am I going to have to pre-process or post-process the data?

xmlParseChunk is somehow a hack, as it not full proper XML parsing.

XInclude itself is not integrated in the parse phase, it's always a
post processing option, for example "xmllint --xinclude" just calls
xmlXIncludeProcessFlags() on the resulting document.

You will have to use xmlXIncludeProcessTreeFlags() on all the top
element node that xmlParseChunk may return to you.

Aha--thanks!  That's good to know.  As far as I can tell, xmlParseChunk   
does not return any xmlNodePtr's--am I wrong?

 my mistake, I though you were using a different API. In that case
you have a document which is buiilt progressively, and if you can
wait until the end of the parse to handle XInclude, then
xmlXIncludeProcessFlags() on the ctxt->doc should be just fine

I may actually be using the API you were thinking of; my comment was 
pretty imprecise.  Currently the project uses the callback functions 
startElementNsSAX2Func, endElementNsSAX2Func, charactersSAXFunc, and a few 
others (but not all possible ones).  These particular ones don't return 
nodes, and I didn't see any others on the list that did either, but I 
thought I might have missed one.

At any rate, overall this looks like a post-processing issue of some form 
or another; I'll investigate.  Thank you again!

-Lucian



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