mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2025-08-07 10:42:55 +03:00
attempst to tweak to get full memory debug... the basic API starts to work
* configure.in python/Makefile.am: attempst to tweak to get full memory debug... * python/generator.py python/libxsl.py python/libxslt-python-api.xml python/libxslt.c python/libxslt_wrap.h python/libxsltclass.txt: the basic API starts to work * python/tests/test.*: first basic test * libxslt/xsltutils.c: fixed a comment Daniel
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
|||||||
|
Wed Feb 6 00:20:57 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* configure.in python/Makefile.am: attempst to tweak to get
|
||||||
|
full memory debug...
|
||||||
|
* python/generator.py python/libxsl.py python/libxslt-python-api.xml
|
||||||
|
python/libxslt.c python/libxslt_wrap.h python/libxsltclass.txt:
|
||||||
|
the basic API starts to work
|
||||||
|
* python/tests/test.*: first basic test
|
||||||
|
* libxslt/xsltutils.c: fixed a comment
|
||||||
|
|
||||||
Tue Feb 5 17:35:00 CET 2002 Daniel Veillard <daniel@veillard.com>
|
Tue Feb 5 17:35:00 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* configure.in doc/Makefile.am: do not install outside of prefix,
|
* configure.in doc/Makefile.am: do not install outside of prefix,
|
||||||
|
@@ -342,9 +342,11 @@ if test "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/XSLT" ; then
|
|||||||
LIBXML_LIBS="../../XML/.libs/libxml2.a -lz"
|
LIBXML_LIBS="../../XML/.libs/libxml2.a -lz"
|
||||||
DV_LINK="1"
|
DV_LINK="1"
|
||||||
XSLTPROCDV="xsltproc.dv"
|
XSLTPROCDV="xsltproc.dv"
|
||||||
|
PYTHONSODV="_libxslt.so.dv"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_SUBST(XSLTPROCDV)
|
AC_SUBST(XSLTPROCDV)
|
||||||
|
AC_SUBST(PYTHONSODV)
|
||||||
AC_SUBST(XML_CONFIG)
|
AC_SUBST(XML_CONFIG)
|
||||||
AC_SUBST(LIBXML_LIBS)
|
AC_SUBST(LIBXML_LIBS)
|
||||||
AC_SUBST(LIBXML_CFLAGS)
|
AC_SUBST(LIBXML_CFLAGS)
|
||||||
|
@@ -924,7 +924,7 @@ xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result,
|
|||||||
* @compression: the compression factor (0 - 9 included)
|
* @compression: the compression factor (0 - 9 included)
|
||||||
*
|
*
|
||||||
* Save the result @result obtained by applying the @style stylesheet
|
* Save the result @result obtained by applying the @style stylesheet
|
||||||
* to a file or URL @URL
|
* to a file or @URL
|
||||||
*
|
*
|
||||||
* Returns the number of byte written or -1 in case of failure.
|
* Returns the number of byte written or -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
|
@@ -19,7 +19,7 @@ EXTRA_DIST = \
|
|||||||
$(DOCS)
|
$(DOCS)
|
||||||
|
|
||||||
if WITH_PYTHON
|
if WITH_PYTHON
|
||||||
all: _libxslt.so libxslt.py
|
all: _libxslt.so libxslt.py $(PYTHONSODV)
|
||||||
|
|
||||||
libxslt.py: $(srcdir)/libxsl.py libxsltclass.py
|
libxslt.py: $(srcdir)/libxsl.py libxsltclass.py
|
||||||
cat $(srcdir)/libxsl.py libxsltclass.py > libxslt.py
|
cat $(srcdir)/libxsl.py libxsltclass.py > libxslt.py
|
||||||
@@ -27,6 +27,10 @@ libxslt.py: $(srcdir)/libxsl.py libxsltclass.py
|
|||||||
_libxslt.so: libxslt.o libxslt-py.o types.o
|
_libxslt.so: libxslt.o libxslt-py.o types.o
|
||||||
$(CC) $(LINK_FLAGS) libxslt.o libxslt-py.o types.o $(LIBS) -o _libxslt.so
|
$(CC) $(LINK_FLAGS) libxslt.o libxslt-py.o types.o $(LIBS) -o _libxslt.so
|
||||||
|
|
||||||
|
_libxslt.so.dv: libxslt.o libxslt-py.o types.o
|
||||||
|
rm -f _libxslt.so
|
||||||
|
$(CC) $(LINK_FLAGS) libxslt.o libxslt-py.o types.o -L../libxslt/.libs -L../libxslt -lxslt -L../libexslt/.libs -L../libexslt -lexslt $(HOME)/XML/python/_libxml.so $(HOME)/XML/.libs/libxml2.a -o _libxslt.so
|
||||||
|
|
||||||
install-data-local:
|
install-data-local:
|
||||||
$(mkinstalldirs) $(DESTDIR)$(PYTHON_SITE_PACKAGES)
|
$(mkinstalldirs) $(DESTDIR)$(PYTHON_SITE_PACKAGES)
|
||||||
-@INSTALL@ -m 0644 libxslt.py $(DESTDIR)$(PYTHON_SITE_PACKAGES)
|
-@INSTALL@ -m 0644 libxslt.py $(DESTDIR)$(PYTHON_SITE_PACKAGES)
|
||||||
|
@@ -265,6 +265,8 @@ py_types = {
|
|||||||
'htmlParserCtxt *': ('O', "parserCtxt", "xmlParserCtxtPtr", "xmlParserCtxtPtr", "libxml_"),
|
'htmlParserCtxt *': ('O', "parserCtxt", "xmlParserCtxtPtr", "xmlParserCtxtPtr", "libxml_"),
|
||||||
'xsltTransformContextPtr': ('O', "transformCtxt", "xsltTransformContextPtr", "xsltTransformContextPtr", "libxslt_"),
|
'xsltTransformContextPtr': ('O', "transformCtxt", "xsltTransformContextPtr", "xsltTransformContextPtr", "libxslt_"),
|
||||||
'xsltTransformContext *': ('O', "transformCtxt", "xsltTransformContextPtr", "xsltTransformContextPtr", "libxslt_"),
|
'xsltTransformContext *': ('O', "transformCtxt", "xsltTransformContextPtr", "xsltTransformContextPtr", "libxslt_"),
|
||||||
|
'xsltStylesheetPtr': ('O', "stylesheet", "xsltStylesheetPtr", "xsltStylesheetPtr", "libxslt_"),
|
||||||
|
'xsltStylesheet *': ('O', "stylesheet", "xsltStylesheetPtr", "xsltStylesheetPtr", "libxslt_"),
|
||||||
}
|
}
|
||||||
|
|
||||||
py_return_types = {
|
py_return_types = {
|
||||||
@@ -507,13 +509,13 @@ converter_type = {
|
|||||||
"xmlXPathObjectPtr": "xpathObjectRet(%s)",
|
"xmlXPathObjectPtr": "xpathObjectRet(%s)",
|
||||||
}
|
}
|
||||||
|
|
||||||
primary_classes = []
|
primary_classes = ["transformCtxt", "stylesheet"]
|
||||||
|
|
||||||
classes_ancestor = {
|
classes_ancestor = {
|
||||||
}
|
}
|
||||||
classes_destructors = {
|
classes_destructors = {
|
||||||
"xpathContext": "xmlXPathFreeContext",
|
"stylesheet": "xsltFreeStylesheet",
|
||||||
"parserCtxt": "xmlFreeParserCtxt",
|
"transformCtxt": "xsltFreeTransformContext",
|
||||||
}
|
}
|
||||||
|
|
||||||
function_classes = {}
|
function_classes = {}
|
||||||
@@ -607,27 +609,7 @@ for name in functions.keys():
|
|||||||
for type in ctypes:
|
for type in ctypes:
|
||||||
classe = classes_type[type][2]
|
classe = classes_type[type][2]
|
||||||
|
|
||||||
if name[0:3] == "xml" and len(args) >= 1 and args[0][1] == type:
|
if name[0:4] == "xslt" and len(args) >= 1 and args[0][1] == type:
|
||||||
found = 1
|
|
||||||
func = nameFixup(name, classe, type, file)
|
|
||||||
info = (0, func, name, ret, args, file)
|
|
||||||
function_classes[classe].append(info)
|
|
||||||
elif name[0:3] == "xml" and len(args) >= 2 and args[1][1] == type:
|
|
||||||
found = 1
|
|
||||||
func = nameFixup(name, classe, type, file)
|
|
||||||
info = (1, func, name, ret, args, file)
|
|
||||||
function_classes[classe].append(info)
|
|
||||||
elif name[0:4] == "html" and len(args) >= 1 and args[0][1] == type:
|
|
||||||
found = 1
|
|
||||||
func = nameFixup(name, classe, type, file)
|
|
||||||
info = (0, func, name, ret, args, file)
|
|
||||||
function_classes[classe].append(info)
|
|
||||||
elif name[0:4] == "html" and len(args) >= 2 and args[1][1] == type:
|
|
||||||
found = 1
|
|
||||||
func = nameFixup(name, classe, type, file)
|
|
||||||
info = (1, func, name, ret, args, file)
|
|
||||||
function_classes[classe].append(info)
|
|
||||||
elif name[0:4] == "xslt" and len(args) >= 1 and args[0][1] == type:
|
|
||||||
found = 1
|
found = 1
|
||||||
func = nameFixup(name, classe, type, file)
|
func = nameFixup(name, classe, type, file)
|
||||||
info = (0, func, name, ret, args, file)
|
info = (0, func, name, ret, args, file)
|
||||||
@@ -637,6 +619,11 @@ for name in functions.keys():
|
|||||||
func = nameFixup(name, classe, type, file)
|
func = nameFixup(name, classe, type, file)
|
||||||
info = (1, func, name, ret, args, file)
|
info = (1, func, name, ret, args, file)
|
||||||
function_classes[classe].append(info)
|
function_classes[classe].append(info)
|
||||||
|
elif name[0:4] == "xslt" and len(args) >= 3 and args[2][1] == type:
|
||||||
|
found = 1
|
||||||
|
func = nameFixup(name, classe, type, file)
|
||||||
|
info = (2, func, name, ret, args, file)
|
||||||
|
function_classes[classe].append(info)
|
||||||
if found == 1:
|
if found == 1:
|
||||||
break
|
break
|
||||||
if found == 1:
|
if found == 1:
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import libxml2
|
from libxml2 import *
|
||||||
import _libxslt
|
import _libxslt
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@@ -5,6 +5,13 @@
|
|||||||
</file>
|
</file>
|
||||||
</files>
|
</files>
|
||||||
<symbols>
|
<symbols>
|
||||||
|
<function name='xsltApplyStylesheet' file='python'>
|
||||||
|
<info>Apply the stylesheet to the document</info>
|
||||||
|
<return type='xmlDocPtr' info="the result document or NULL in case of error"/>
|
||||||
|
<arg name='style' type='xsltStylesheetPtr' info='a parsed XSLT stylesheet'/>
|
||||||
|
<arg name='doc' type='xmlDocPtr' info='a parsed XML document'/>
|
||||||
|
<arg name='params' type='pythonObject' info='the parameters dictionnary'/>
|
||||||
|
</function>
|
||||||
<!--
|
<!--
|
||||||
<function name='xsltRegisterXPathFunction' file='python'>
|
<function name='xsltRegisterXPathFunction' file='python'>
|
||||||
<info>Register a Python written function to the XPath interpreter</info>
|
<info>Register a Python written function to the XPath interpreter</info>
|
||||||
|
@@ -20,6 +20,42 @@
|
|||||||
/* #define DEBUG_ERROR */
|
/* #define DEBUG_ERROR */
|
||||||
/* #define DEBUG_MEMORY */
|
/* #define DEBUG_MEMORY */
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* *
|
||||||
|
* Per type specific glue *
|
||||||
|
* *
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
PyObject *
|
||||||
|
libxslt_xsltStylesheetPtrWrap(xsltStylesheetPtr style) {
|
||||||
|
PyObject *ret;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("libxslt_xsltStylesheetPtrWrap: style = %p\n", style);
|
||||||
|
#endif
|
||||||
|
if (style == NULL) {
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return(Py_None);
|
||||||
|
}
|
||||||
|
ret = PyCObject_FromVoidPtrAndDesc((void *) style, "xsltStylesheetPtr", NULL);
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject *
|
||||||
|
libxslt_xsltTransformContextPtrWrap(xsltTransformContextPtr ctxt) {
|
||||||
|
PyObject *ret;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("libxslt_xsltTransformContextPtrWrap: ctxt = %p\n", ctxt);
|
||||||
|
#endif
|
||||||
|
if (ctxt == NULL) {
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return(Py_None);
|
||||||
|
}
|
||||||
|
ret = PyCObject_FromVoidPtrAndDesc((void *) ctxt, "xsltTransformContextPtr", NULL);
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* Memory debug interface *
|
* Memory debug interface *
|
||||||
@@ -105,6 +141,40 @@ libxslt_xmlDumpMemory(PyObject *self, PyObject *args) {
|
|||||||
return(Py_None);
|
return(Py_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* *
|
||||||
|
* Some customized front-ends *
|
||||||
|
* *
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
PyObject *
|
||||||
|
libxslt_xsltApplyStylesheet(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *py_retval;
|
||||||
|
xmlDocPtr c_retval;
|
||||||
|
xsltStylesheetPtr style;
|
||||||
|
PyObject *pyobj_style;
|
||||||
|
xmlDocPtr doc;
|
||||||
|
PyObject *pyobj_doc;
|
||||||
|
PyObject *pyobj_params;
|
||||||
|
char **params;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "OOO:xsltApplyStylesheet", &pyobj_style, &pyobj_doc, &pyobj_params))
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
|
if (pyobj_params != Py_None) {
|
||||||
|
printf("libxslt_xsltApplyStylesheet: parameters not yet supported\n");
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return(Py_None);
|
||||||
|
} else {
|
||||||
|
params = NULL;
|
||||||
|
}
|
||||||
|
style = (xsltStylesheetPtr) Pystylesheet_Get(pyobj_style);
|
||||||
|
doc = (xmlDocPtr) PyxmlNode_Get(pyobj_doc);
|
||||||
|
|
||||||
|
c_retval = xsltApplyStylesheet(style, doc, params);
|
||||||
|
py_retval = libxml_xmlDocPtrWrap((xmlDocPtr) c_retval);
|
||||||
|
return(py_retval);
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
|
@@ -34,5 +34,5 @@ typedef struct {
|
|||||||
xsltTransformContextPtr obj;
|
xsltTransformContextPtr obj;
|
||||||
} PytransformCtxt_Object;
|
} PytransformCtxt_Object;
|
||||||
|
|
||||||
PyObject * libxslt_xsltTransformContextPtr(xsltTransformContextPtr ctxt);
|
PyObject * libxslt_xsltStylesheetPtrWrap(xsltStylesheetPtr ctxt);
|
||||||
PyObject * libxslt_xsltStylesheetPtr(xsltStylesheetPtr ctxt);
|
PyObject * libxslt_xsltTransformContextPtrWrap(xsltTransformContextPtr ctxt);
|
||||||
|
@@ -27,6 +27,9 @@ cleanupGlobals()
|
|||||||
|
|
||||||
# functions from module xsltInternals
|
# functions from module xsltInternals
|
||||||
isBlank()
|
isBlank()
|
||||||
|
loadStylesheetPI()
|
||||||
|
newStylesheet()
|
||||||
|
parseStylesheetDoc()
|
||||||
|
|
||||||
# functions from module xsltutils
|
# functions from module xsltutils
|
||||||
calibrateAdjust()
|
calibrateAdjust()
|
||||||
@@ -90,4 +93,59 @@ Class transformCtxt()
|
|||||||
|
|
||||||
# functions from module xsltutils
|
# functions from module xsltutils
|
||||||
message()
|
message()
|
||||||
|
printErrorContext()
|
||||||
Class stylesheet()
|
Class stylesheet()
|
||||||
|
|
||||||
|
# functions from module attributes
|
||||||
|
freeAttributeSetsHashes()
|
||||||
|
parseStylesheetAttributeSet()
|
||||||
|
|
||||||
|
# functions from module documents
|
||||||
|
freeStyleDocuments()
|
||||||
|
|
||||||
|
# functions from module extensions
|
||||||
|
checkExtPrefix()
|
||||||
|
freeExts()
|
||||||
|
registerExtPrefix()
|
||||||
|
shutdownExts()
|
||||||
|
|
||||||
|
# functions from module imports
|
||||||
|
nextImport()
|
||||||
|
parseStylesheetImport()
|
||||||
|
parseStylesheetInclude()
|
||||||
|
|
||||||
|
# functions from module keys
|
||||||
|
addKey()
|
||||||
|
freeKeys()
|
||||||
|
|
||||||
|
# functions from module namespaces
|
||||||
|
freeNamespaceAliasHashes()
|
||||||
|
namespaceAlias()
|
||||||
|
|
||||||
|
# functions from module pattern
|
||||||
|
cleanupTemplates()
|
||||||
|
freeTemplateHashes()
|
||||||
|
|
||||||
|
# functions from module preproc
|
||||||
|
freeStylePreComps()
|
||||||
|
stylePreCompute()
|
||||||
|
|
||||||
|
# functions from module python
|
||||||
|
applyStylesheet()
|
||||||
|
|
||||||
|
# functions from module transform
|
||||||
|
newTransformContext()
|
||||||
|
|
||||||
|
# functions from module variables
|
||||||
|
parseGlobalParam()
|
||||||
|
parseGlobalVariable()
|
||||||
|
|
||||||
|
# functions from module xsltInternals
|
||||||
|
freeStylesheet()
|
||||||
|
parseStylesheetOutput()
|
||||||
|
parseStylesheetProcess()
|
||||||
|
parseTemplateContent()
|
||||||
|
|
||||||
|
# functions from module xsltutils
|
||||||
|
saveResultToFd()
|
||||||
|
saveResultToFilename()
|
||||||
|
9
python/tests/test.py
Executable file
9
python/tests/test.py
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/python -u
|
||||||
|
import libxml2
|
||||||
|
import libxslt
|
||||||
|
|
||||||
|
styledoc = libxml2.parseFile("test.xsl")
|
||||||
|
style = libxslt.parseStylesheetDoc(styledoc)
|
||||||
|
doc = libxml2.parseFile("test.xml")
|
||||||
|
result = style.applyStylesheet(doc, None)
|
||||||
|
result.saveFile("-")
|
1
python/tests/test.xml
Normal file
1
python/tests/test.xml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<test/>
|
9
python/tests/test.xsl
Normal file
9
python/tests/test.xsl
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<xsl:stylesheet version="1.0"
|
||||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||||
|
|
||||||
|
<xsl:template match="/">
|
||||||
|
<article>
|
||||||
|
<title>Hello World</title>
|
||||||
|
</article>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
Reference in New Issue
Block a user