removed a warning added xsltRunStylesheetUser() API needed to fix #78546
authorDaniel Veillard <veillard@src.gnome.org>
Mon, 15 Apr 2002 15:30:21 +0000 (15:30 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Mon, 15 Apr 2002 15:30:21 +0000 (15:30 +0000)
* 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
libxslt/attributes.c
libxslt/transform.c
libxslt/transform.h
win32/libxslt.def.src
xsltproc/xsltproc.c

index 8204772..70738e2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Apr 15 17:27:51 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * 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 <daniel@veillard.com>
 
        * python/Makefile.am: fixing the equivalent of #75779
index ce295d5..b1c6b75 100644 (file)
@@ -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;
 
index 85210c7..38c5e40 100644 (file)
@@ -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
  *
index 7223bd6..c94eda6 100644 (file)
@@ -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,
index a7acba2..5687cc5 100644 (file)
@@ -200,6 +200,7 @@ EXPORTS
        xsltApplyStylesheet
        xsltProfileStylesheet
        xsltRunStylesheet
+       xsltRunStylesheetUser
        xsltApplyOneTemplate
        xsltDocumentElem
        xsltSort
index 23660b1..af65d48 100644 (file)
@@ -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);