Re: [xslt] stream xsl



On Tue, Mar 23, 2004 at 03:58:27PM -0700, Utkarsh Shah wrote:
> Daniel,
>         I looked at the push parser API's but was not able to find out 
> how I to get xmlDocPtr. Here is sample functions calls I am  thinking 
> about,
> void    xmlInitParser                   (void)
> xmlParserCtxtPtr        xmlCreatePushParserCtxt (xmlSAXHandlerPtr sax,
>                                           void * user_data,
>                                               const char * chunk,
>                                             int size,
>                                               const char * filename)
> 
> while(there is more data)
> {
> 	int     xmlParseChunk                   (xmlParserCtxtPtr ctxt,
>          	                                const char * chunk,
>          	                           int size,
>          	                             int terminate)
> }
> //??How to get xmlDocPtr
> void    xmlStopParser                   (xmlParserCtxtPtr ctxt)
> 
> Is there any sample code available for push parsing? Am I looking at 
> right function calls or missing something?

  xmlStopParser is not the right thing, the terminate flag is the one
indicating the end. There is some sample code in xmllint.c in the
source distribution:

                    ctxt = xmlCreatePushParserCtxt(NULL, NULL,
                                chars, res, filename);
                    xmlCtxtUseOptions(ctxt, options);
                    while ((res = fread(chars, 1, size, f)) > 0) {
                        xmlParseChunk(ctxt, chars, res, 0);
                    }
                    xmlParseChunk(ctxt, chars, 0, 1);
                    doc = ctxt->myDoc;
                    ret = ctxt->wellFormed;
                    xmlFreeParserCtxt(ctxt);
                    if (!ret) {
                        xmlFreeDoc(doc);
                        doc = NULL;
                    }

  it would be useful to build a clean example for push to integrate
in the set of examples http://xmlsoft.org/examples/index.html

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]