+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
<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>
<h2>Type int *:</h2>
<p>
<a href="html/libxslt-templates.html#XSLTEVALSTATICATTRVALUETEMPLATE">xsltEvalStaticAttrValueTemplate</a>
+<a href="">xsltSaveResultToString</a>
</p>
<h2>Type long:</h2>
<p>
<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>
<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>
<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>
<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'/>
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
</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'/>
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 *
int xsltSaveResultToFd (int fd,
xmlDocPtr result,
xsltStylesheetPtr style);
+int xsltSaveResultToString (xmlChar **doc_txt_ptr,
+ int * doc_txt_len,
+ xmlDocPtr result,
+ xsltStylesheetPtr style);
/*
* Profiling.