diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2002-08-25 15:04:00 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2002-08-25 15:04:00 +0000 |
commit | f015c8f98ccdaa929367caf1894effa6d41a02ed (patch) | |
tree | a868dafca880156bd244bed2a6ec503eb417c2a5 /python/libxslt.c | |
parent | c1d306b3c309de20cddc70e92ab5c76ca924fe41 (diff) | |
download | libxslt-f015c8f98ccdaa929367caf1894effa6d41a02ed.tar.gz libxslt-f015c8f98ccdaa929367caf1894effa6d41a02ed.tar.bz2 libxslt-f015c8f98ccdaa929367caf1894effa6d41a02ed.zip |
applied a patch from Ralf Mattes providing style.saveResultToString()
* python/libxslt-python-api.xml python/libxslt.c
python/libxsltclass.txt python/tests/basic.py: applied a patch
from Ralf Mattes providing style.saveResultToString()
Daniel
Diffstat (limited to 'python/libxslt.c')
-rw-r--r-- | python/libxslt.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/python/libxslt.c b/python/libxslt.c index 5809c203..9ab20f89 100644 --- a/python/libxslt.c +++ b/python/libxslt.c @@ -251,6 +251,49 @@ libxslt_xsltApplyStylesheet(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { return(py_retval); } +PyObject * +libxslt_xsltSaveResultToString(PyObject *self, PyObject *args) { + PyObject *py_retval; /* our final return value, a python string */ + xmlChar *buffer; + xmlChar *tmp; + int size = 0; + int emitted = 0; + xmlDocPtr result; + PyObject *pyobj_result; + xsltStylesheetPtr style; + PyObject *pyobj_style; + + if (!PyArg_ParseTuple(args, (char *)"OO:xsltSaveResultToString", &pyobj_style, &pyobj_result)) + goto FAIL; + result = (xmlDocPtr) PyxmlNode_Get(pyobj_result); + style = (xsltStylesheetPtr) Pystylesheet_Get(pyobj_style); + + + /* FIXME: We should probably add more restrictive error checking + * and raise an error instead of "just" returning NULL. + * FIXME: Documentation and code for xsltSaveResultToString diff + * -> emmitted will never be positive non-null. + */ + emitted = xsltSaveResultToString(&buffer, &size, result, style); + if(!buffer || emitted < 0) + goto FAIL; + /* We haven't tested the aberrant case of a transformation that + * renders to an empty string. For now we try to play it save. + */ + if(size) + { + buffer[size] = '\0'; + py_retval = PyString_FromString((char *) buffer); + xmlFree(buffer); + } + else + py_retval = PyString_FromString(""); + return(py_retval); + FAIL: + return(0); +} + + /************************************************************************ * * * Error message callback * |