From 6ca5fcf67bafcee7191d074b5449fa0a88514608 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Mon, 15 Apr 2002 15:30:21 +0000 Subject: [PATCH] removed a warning added xsltRunStylesheetUser() API needed to fix #78546 * libxslt/attributes.c: removed a warning * libxslt/transform.c libxslt/transform.h win32/libxslt.def.src: added xsltRunStylesheetUser() API needed to fix #78546 * xsltproc/xsltproc.c: second part of the fix #78546 Daniel --- ChangeLog | 7 +++++++ libxslt/attributes.c | 2 +- libxslt/transform.c | 45 +++++++++++++++++++++++++++++++++++++++++---- libxslt/transform.h | 8 ++++++++ win32/libxslt.def.src | 1 + xsltproc/xsltproc.c | 16 +++++++++++++++- 6 files changed, 73 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8204772..70738e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Apr 15 17:27:51 CEST 2002 Daniel Veillard + + * libxslt/attributes.c: removed a warning + * libxslt/transform.c libxslt/transform.h win32/libxslt.def.src: + added xsltRunStylesheetUser() API needed to fix #78546 + * xsltproc/xsltproc.c: second part of the fix #78546 + Mon Apr 15 15:57:28 CEST 2002 Daniel Veillard * python/Makefile.am: fixing the equivalent of #75779 diff --git a/libxslt/attributes.c b/libxslt/attributes.c index ce295d5..b1c6b75 100644 --- a/libxslt/attributes.c +++ b/libxslt/attributes.c @@ -439,7 +439,7 @@ xsltGetSAS(xsltStylesheetPtr style, const xmlChar *name, const xmlChar *ns) { static void xsltResolveSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style, const xmlChar *name, const xmlChar *ns, - const xmlChar *ignored) { + ATTRIBUTE_UNUSED const xmlChar *ignored) { xsltAttrElemPtr tmp; xsltAttrElemPtr refs; diff --git a/libxslt/transform.c b/libxslt/transform.c index 85210c7..38c5e40 100644 --- a/libxslt/transform.c +++ b/libxslt/transform.c @@ -3700,13 +3700,15 @@ xsltApplyStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc, } /** - * xsltRunStylesheet: + * xsltRunStylesheetUser: * @style: a parsed XSLT stylesheet * @doc: a parsed XML document * @params: a NULL terminated arry of parameters names/values tuples * @output: the URL/filename ot the generated resource if available * @SAX: a SAX handler for progressive callback output (not implemented yet) * @IObuf: an output buffer for progressive output (not implemented yet) + * @profile: profile FILE * output or NULL + * @userCtxt: user provided transform context * * Apply the stylesheet to the document and generate the output according * to @output @SAX and @IObuf. It's an error to specify both @SAX and @IObuf. @@ -3724,9 +3726,10 @@ xsltApplyStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc, * error. */ int -xsltRunStylesheet(xsltStylesheetPtr style, xmlDocPtr doc, +xsltRunStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc, const char **params, const char *output, - xmlSAXHandlerPtr SAX, xmlOutputBufferPtr IObuf) + xmlSAXHandlerPtr SAX, xmlOutputBufferPtr IObuf, + FILE * profile, xsltTransformContextPtr userCtxt) { xmlDocPtr tmp; int ret; @@ -3742,7 +3745,8 @@ xsltRunStylesheet(xsltStylesheetPtr style, xmlDocPtr doc, return (-1); } - tmp = xsltApplyStylesheetInternal(style, doc, params, output, NULL, NULL); + tmp = xsltApplyStylesheetInternal(style, doc, params, output, profile, + userCtxt); if (tmp == NULL) { xsltPrintErrorContext(NULL, NULL, (xmlNodePtr) doc); xsltGenericError(xsltGenericErrorContext, @@ -3760,6 +3764,39 @@ xsltRunStylesheet(xsltStylesheetPtr style, xmlDocPtr doc, } /** + * xsltRunStylesheet: + * @style: a parsed XSLT stylesheet + * @doc: a parsed XML document + * @params: a NULL terminated arry of parameters names/values tuples + * @output: the URL/filename ot the generated resource if available + * @SAX: a SAX handler for progressive callback output (not implemented yet) + * @IObuf: an output buffer for progressive output (not implemented yet) + * + * Apply the stylesheet to the document and generate the output according + * to @output @SAX and @IObuf. It's an error to specify both @SAX and @IObuf. + * + * NOTE: This may lead to a non-wellformed output XML wise ! + * NOTE: This may also result in multiple files being generated + * NOTE: using IObuf, the result encoding used will be the one used for + * creating the output buffer, use the following macro to read it + * from the stylesheet + * XSLT_GET_IMPORT_PTR(encoding, style, encoding) + * NOTE: using SAX, any encoding specified in the stylesheet will be lost + * since the interface uses only UTF8 + * + * Returns the number of by written to the main resource or -1 in case of + * error. + */ +int +xsltRunStylesheet(xsltStylesheetPtr style, xmlDocPtr doc, + const char **params, const char *output, + xmlSAXHandlerPtr SAX, xmlOutputBufferPtr IObuf) +{ + return(xsltRunStylesheetUser(style, doc, params, output, SAX, IObuf, + NULL, NULL)); +} + +/** * xsltRegisterAllElement: * @ctxt: the XPath context * diff --git a/libxslt/transform.h b/libxslt/transform.h index 7223bd6..c94eda6 100644 --- a/libxslt/transform.h +++ b/libxslt/transform.h @@ -60,6 +60,14 @@ int xsltRunStylesheet (xsltStylesheetPtr style, const char *output, xmlSAXHandlerPtr SAX, xmlOutputBufferPtr IObuf); +int xsltRunStylesheetUser (xsltStylesheetPtr style, + xmlDocPtr doc, + const char **params, + const char *output, + xmlSAXHandlerPtr SAX, + xmlOutputBufferPtr IObuf, + FILE * profile, + xsltTransformContextPtr userCtxt); void xsltApplyOneTemplate (xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr list, diff --git a/win32/libxslt.def.src b/win32/libxslt.def.src index a7acba2..5687cc5 100644 --- a/win32/libxslt.def.src +++ b/win32/libxslt.def.src @@ -200,6 +200,7 @@ EXPORTS xsltApplyStylesheet xsltProfileStylesheet xsltRunStylesheet + xsltRunStylesheetUser xsltApplyOneTemplate xsltDocumentElem xsltSort diff --git a/xsltproc/xsltproc.c b/xsltproc/xsltproc.c index 23660b1..af65d48 100644 --- a/xsltproc/xsltproc.c +++ b/xsltproc/xsltproc.c @@ -331,7 +331,21 @@ xsltProcess(xmlDocPtr doc, xsltStylesheetPtr cur, const char *filename) { xmlFreeDoc(res); } else { - xsltRunStylesheet(cur, doc, params, output, NULL, NULL); + int ret; + + ctxt = xsltNewTransformContext(cur, doc); + if (ctxt == NULL) + return; + if (profile) { + ret = xsltRunStylesheetUser(cur, doc, params, output, + NULL, NULL, stderr, ctxt); + } else { + ret = xsltRunStylesheetUser(cur, doc, params, output, + NULL, NULL, NULL, ctxt); + } + if (ctxt->state == XSLT_STATE_ERROR) + errorno = 9; + xsltFreeTransformContext(ctxt); if (timing) endTimer("Running stylesheet and saving result"); xmlFreeDoc(doc); -- 2.7.4