Re: [xslt] ParserCtxt for xslt parsing



Hi

My apologies - I misread your question.

>From what I can tell, there's no way of setting the error handler using
xsltParseStylesheetFile.
However, all xsltParseStylesheetFile() does is call xmlParseFile(), then
calls xsltParseStylesheetDoc().

The easiest way of setting the error handler is to write your own version
of xsltParseStylesheet,
giving you more control over things like the error handlers.
For example,

/* Warning - not tested... */
xsltStylesheetPtr
xsltMyParseStylesheetFile(const xmlChar* filename) {
    xsltStylesheetPtr ret;
    xmlDocPtr doc;
    xmlParserCtxtPtr ctxt;

/* Set up XML error handler */
    ctxt = xmlCreateFileParserCtxt(filename);
    xmlSetGenericErrorFunc(ctxt,xml_error);

/* Parse XML File */
    xmlParseDocument(ctxt);
    doc=xmlctxt->myDoc;

/* Set up XSLT error handler */
    xsltSetGenericErrorFunc(ctxt,xslt_error);

/* Parse Stylesheet */
    ret = xsltParseStylesheetDoc(doc);

    return ret;
}

Richard

----- Original Message ----- 
From: "Jean Senellart" <senellart@systran.fr>
To: <xslt@gnome.org>
Sent: Friday, June 27, 2003 7:29 PM
Subject: Re: [xslt] ParserCtxt for xslt parsing


> Hi
>
> Thanks for the link, but I do not see how to use this function for
parsing the Stylesheet. more specifically how can I use a ParserContext
for xsltParseStylesheetFile?
>
> Concerning xsltSetGenericErrorFunc, I do have use of it, in fact, for
applying the stylesheet:
>   xsltTransformContextPtr xsltctxt=xsltNewTransformContext(cur,doc);
>   xsltSetGenericErrorFunc(xsltctxt,xml_error);
>   res=xsltApplyStylesheetUser(cur,doc,params,NULL,NULL,xsltctxt);
>   xsltFreeTransformContext(xsltctxt);
>
>
>
> Jean
>
>
> Richard Jinks writes:
>  > Hi Jean
>  >
>  > There is an equivalent XSLT function, xsltSetGenericErrorFunc() in
>  > xsltutils.c
>  >
http://xmlsoft.org/XSLT/html/libxslt-xsltutils.html#xsltSetGenericErrorFunc
>  >
>  > Hope this helps,
>  > Richard
>  >
>  > ----- Original Message ----- 
>  > From: "Jean Senellart" <senellart@systran.fr>
>  > To: <xslt@gnome.org>
>  > Sent: Thursday, June 26, 2003 11:01 PM
>  > Subject: [xslt] ParserCtxt for xslt parsing
>  >
>  >
>  > >
>  > > Hi,
>  > >
>  > > I do not find how I can set a error handler for parsing xslt file
>  > (xsltParseStylesheetFile), i.e the equivalent of the following for
the
>  > parsing xml file (xmlParseFile):
>  > >
>  > >   xmlParserCtxtPtr xmlctxt =
xmlCreateFileParserCtxt(XmlDoc.c_str());
>  > >   xmlSetGenericErrorFunc(xmlctxt,xml_error);
>  > >   xmlParseDocument(xmlctxt);
>  > >   doc=xmlctxt->myDoc;
>  > >
>  > >
>  > > is there something equivalent existing?
>  > >
>  > > I want also to report that the following link is broken:
>  > >
>  >
http://www.xmlsoft.org/html/libxml-parserinternals.html#XMLCREATEMEMORYPARSERCTXT
>  > > it is the result of Search(Only the APIs): xmlCreateFileParserCtxt
>  > >
>  > > thanks,
>  > > Jean S.
>  > >
>  > >
>  > > _______________________________________________
>  > > xslt mailing list, project page http://xmlsoft.org/XSLT/
>  > > xslt@gnome.org
>  > > http://mail.gnome.org/mailman/listinfo/xslt
>  >
>  > _______________________________________________
>  > xslt mailing list, project page http://xmlsoft.org/XSLT/
>  > xslt@gnome.org
>  > http://mail.gnome.org/mailman/listinfo/xslt
>  >
> _______________________________________________
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> xslt@gnome.org
> http://mail.gnome.org/mailman/listinfo/xslt




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