applied patch from Morus Walter adding xsltSaveResultToString() this
authorDaniel Veillard <veillard@src.gnome.org>
Thu, 23 May 2002 16:07:50 +0000 (16:07 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Thu, 23 May 2002 16:07:50 +0000 (16:07 +0000)
* libxslt/xsltutils.[ch] : applied patch from Morus Walter
  adding xsltSaveResultToString()
* doc/APIfiles.html doc/APIfunctions.html doc/libxslt-api.xml
  doc/libxslt-decl.txt doc/libxslt-refs.xml: this increased the
  API with the new function.
Daniel

ChangeLog
doc/APIfiles.html
doc/APIfunctions.html
doc/libxslt-api.xml
doc/libxslt-decl.txt
doc/libxslt-refs.xml
libxslt/xsltutils.c
libxslt/xsltutils.h

index 02d0454..9189141 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu May 23 17:28:35 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/xsltutils.[ch] : applied patch from Morus Walter
+         adding xsltSaveResultToString()
+       * doc/APIfiles.html doc/APIfunctions.html doc/libxslt-api.xml
+         doc/libxslt-decl.txt doc/libxslt-refs.xml: this increased the
+         API with the new function.
+
 Wed May 22 11:50:36 CEST 2002 Daniel Veillard <daniel@veillard.com>
 
        * libxslt/function.c: applied a patch from Richard Jinks
index 8cfdd03..9f279a0 100644 (file)
@@ -364,6 +364,7 @@ A:link, A:visited, A:active { text-decoration: underline }
 <a href="html/libxslt-xsltutils.html#XSLTSAVERESULTTOFILENAME">xsltSaveResultToFilename</a>
 <a href="html/libxslt-xsltutils.html#XSLTSAVERESULTTOFILE">xsltSaveResultToFile</a>
 <a href="html/libxslt-xsltutils.html#XSLTSAVERESULTTOFD">xsltSaveResultToFd</a>
+<a href="">xsltSaveResultToString</a>
 <a href="html/libxslt-xsltutils.html#XSLTSAVEPROFILING">xsltSaveProfiling</a>
 <a href="html/libxslt-xsltutils.html#XSLTTIMESTAMP">xsltTimestamp</a>
 <a href="html/libxslt-xsltutils.html#XSLTCALIBRATEADJUST">xsltCalibrateAdjust</a>
index 10bb252..dd96bfc 100644 (file)
@@ -184,6 +184,7 @@ A:link, A:visited, A:active { text-decoration: underline }
 <h2>Type int *:</h2>
 <p>
 <a href="html/libxslt-templates.html#XSLTEVALSTATICATTRVALUETEMPLATE">xsltEvalStaticAttrValueTemplate</a>
+<a href="">xsltSaveResultToString</a>
 </p>
 <h2>Type long:</h2>
 <p>
@@ -214,6 +215,7 @@ A:link, A:visited, A:active { text-decoration: underline }
 <p>
 <a href="html/libxslt-xsltinternals.html#XSLTFORMATNUMBERCONVERSION">xsltFormatNumberConversion</a>
 <a href="html/libxslt-xsltutils.html#XSLTGETQNAMEURI">xsltGetQNameURI</a>
+<a href="">xsltSaveResultToString</a>
 </p>
 <h2>Type xmlDocPtr:</h2>
 <p>
@@ -235,6 +237,7 @@ A:link, A:visited, A:active { text-decoration: underline }
 <a href="html/libxslt-xsltutils.html#XSLTSAVERESULTTOFILENAME">xsltSaveResultToFilename</a>
 <a href="html/libxslt-xsltutils.html#XSLTSAVERESULTTOFILE">xsltSaveResultToFile</a>
 <a href="html/libxslt-xsltutils.html#XSLTSAVERESULTTOFD">xsltSaveResultToFd</a>
+<a href="">xsltSaveResultToString</a>
 </p>
 <h2>Type xmlGenericErrorFunc:</h2>
 <p>
@@ -524,6 +527,7 @@ A:link, A:visited, A:active { text-decoration: underline }
 <a href="html/libxslt-xsltutils.html#XSLTSAVERESULTTOFILENAME">xsltSaveResultToFilename</a>
 <a href="html/libxslt-xsltutils.html#XSLTSAVERESULTTOFILE">xsltSaveResultToFile</a>
 <a href="html/libxslt-xsltutils.html#XSLTSAVERESULTTOFD">xsltSaveResultToFd</a>
+<a href="">xsltSaveResultToString</a>
 </p>
 <h2>Type xsltTemplatePtr:</h2>
 <p>
index fbdabe3..9628ec2 100644 (file)
@@ -19,6 +19,7 @@
      <exports symbol='xsltSaveResultToFilename'/>
      <exports symbol='xsltSaveResultToFile'/>
      <exports symbol='xsltSaveResultToFd'/>
+     <exports symbol='xsltSaveResultToString'/>
      <exports symbol='xsltSaveProfiling'/>
      <exports symbol='xsltTimestamp'/>
      <exports symbol='xsltCalibrateAdjust'/>
       <arg name='style' type='xsltStylesheetPtr' info='the stylesheet '/>
       <arg name='compression' type='int' info='the compression factor (0 - 9 included) '/>
     </function>
+    <function name='xsltSaveResultToString' file='xsltutils'>
+      <return type='int'/>
+      <arg name='doc_txt_ptr' type='xmlChar **'/>
+      <arg name='doc_txt_len' type='int *'/>
+      <arg name='result' type='xmlDocPtr'/>
+      <arg name='style' type='xsltStylesheetPtr'/>
+    </function>
     <function name='xsltSetDebuggerCallbacks' file='xsltutils'>
       <return type='int'/>
       <arg name='no' type='int'/>
index 3375b91..919c025 100644 (file)
@@ -1502,6 +1502,11 @@ FILE *file,xmlDocPtr result,xsltStylesheetPtr style
 int fd,xmlDocPtr result,xsltStylesheetPtr style
 </FUNCTION>
 <FUNCTION>
+<NAME>xsltSaveResultToString</NAME>
+<RETURNS>int  </RETURNS>
+xmlChar **doc_txt_ptr,int * doc_txt_len,xmlDocPtr result,xsltStylesheetPtr style
+</FUNCTION>
+<FUNCTION>
 <NAME>xsltSaveProfiling</NAME>
 <RETURNS>void  </RETURNS>
 xsltTransformContextPtr ctxt,FILE *output
index 2448e00..be46598 100644 (file)
     </type>
     <type name='int *'>
       <ref name='xsltEvalStaticAttrValueTemplate'/>
+      <ref name='xsltSaveResultToString'/>
     </type>
     <type name='long'>
       <ref name='xsltCalibrateAdjust'/>
     <type name='xmlChar **'>
       <ref name='xsltFormatNumberConversion'/>
       <ref name='xsltGetQNameURI'/>
+      <ref name='xsltSaveResultToString'/>
     </type>
     <type name='xmlDocPtr'>
       <ref name='xsltNewDocument'/>
       <ref name='xsltSaveResultToFilename'/>
       <ref name='xsltSaveResultToFile'/>
       <ref name='xsltSaveResultToFd'/>
+      <ref name='xsltSaveResultToString'/>
     </type>
     <type name='xmlGenericErrorFunc'>
       <ref name='xsltSetGenericErrorFunc'/>
       <ref name='xsltSaveResultToFilename'/>
       <ref name='xsltSaveResultToFile'/>
       <ref name='xsltSaveResultToFd'/>
+      <ref name='xsltSaveResultToString'/>
     </type>
     <type name='xsltTemplatePtr'>
       <ref name='xsltAddTemplate'/>
       <ref name='xsltSaveResultToFilename'/>
       <ref name='xsltSaveResultToFile'/>
       <ref name='xsltSaveResultToFd'/>
+      <ref name='xsltSaveResultToString'/>
       <ref name='xsltSaveProfiling'/>
       <ref name='xsltTimestamp'/>
       <ref name='xsltCalibrateAdjust'/>
index 0cdabc6..817d76e 100644 (file)
@@ -1049,6 +1049,58 @@ xsltSaveResultToFd(int fd, xmlDocPtr result, xsltStylesheetPtr style) {
     return(ret);
 }
 
+/**
+ * xsltSaveResultToString:
+ * @doc_txt_ptr:  Memory pointer for allocated XML text
+ * @doc_txt_len:  Length of the generated XML text
+ * @result:  the result xmlDocPtr
+ * @style:  the stylesheet
+ * @compression:  the compression factor (0 - 9 included)
+ *
+ * Save the result @result obtained by applying the @style stylesheet
+ * to a file or @URL
+ *
+ * Returns the number of byte written or -1 in case of failure.
+ */
+int
+xsltSaveResultToString(xmlChar **doc_txt_ptr, int * doc_txt_len, 
+                      xmlDocPtr result, xsltStylesheetPtr style) {
+    xmlOutputBufferPtr buf;
+    const xmlChar *encoding;
+    int ret;
+
+    *doc_txt_ptr = NULL;
+    *doc_txt_len = 0;
+    if (result->children == NULL)
+       return(0);
+
+    XSLT_GET_IMPORT_PTR(encoding, style, encoding)
+    if (encoding != NULL) {
+       xmlCharEncodingHandlerPtr encoder;
+
+       encoder = xmlFindCharEncodingHandler((char *)encoding);
+       if ((encoder != NULL) &&
+           (xmlStrEqual((const xmlChar *)encoder->name,
+                        (const xmlChar *) "UTF-8")))
+           encoder = NULL;
+       buf = xmlAllocOutputBuffer(encoder);
+    } else {
+       buf = xmlAllocOutputBuffer(NULL);
+    }
+    if (buf == NULL)
+       return(-1);
+    xsltSaveResultTo(buf, result, style);
+    if (buf->conv != NULL) {
+       *doc_txt_len = buf->conv->use;
+       *doc_txt_ptr = xmlStrndup(buf->conv->content, *doc_txt_len);
+    } else {
+       *doc_txt_len = buf->buffer->use;
+       *doc_txt_ptr = xmlStrndup(buf->buffer->content, *doc_txt_len);
+    }
+    (void)xmlOutputBufferClose(buf);
+    return 0;
+}
+
 /************************************************************************
  *                                                                     *
  *             Generating profiling informations                       *
index 178d0cb..f6fda10 100644 (file)
@@ -142,6 +142,10 @@ int                xsltSaveResultToFile            (FILE *file,
 int            xsltSaveResultToFd              (int fd,
                                                 xmlDocPtr result,
                                                 xsltStylesheetPtr style);
+int             xsltSaveResultToString          (xmlChar **doc_txt_ptr, 
+                                                 int * doc_txt_len, 
+                                                 xmlDocPtr result, 
+                                                 xsltStylesheetPtr style);
 
 /*
  * Profiling.