diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2002-02-06 23:03:38 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2002-02-06 23:03:38 +0000 |
commit | ff22c1a5f95bccd0b400d251dfde04280a6c7d52 (patch) | |
tree | 07d6f358069dda33cf56183e352df78d34dcb291 | |
parent | 09af30e51e8a99072f35ff856c095464afbc0441 (diff) | |
download | libxslt-ff22c1a5f95bccd0b400d251dfde04280a6c7d52.tar.gz libxslt-ff22c1a5f95bccd0b400d251dfde04280a6c7d52.tar.bz2 libxslt-ff22c1a5f95bccd0b400d251dfde04280a6c7d52.zip |
added libxslt_xsltCleanup() added parameters to
* python/libxsl.py python/libxslt-python-api.xml python/libxslt.c
python/libxsltclass.txt: added libxslt_xsltCleanup() added parameters
to libxslt_xsltApplyStylesheet() removed the memleaks left and
fixed an import order.
* python/tests/basic.py python/tests/extfunc.py: updated the tests
Daniel
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | doc/libxslt-api.xml | 97 | ||||
-rw-r--r-- | doc/libxslt-decl.txt | 962 | ||||
-rw-r--r-- | doc/libxslt-refs.xml | 42 | ||||
-rw-r--r-- | python/libxsl.py | 1 | ||||
-rw-r--r-- | python/libxslt-python-api.xml | 4 | ||||
-rw-r--r-- | python/libxslt.c | 78 | ||||
-rw-r--r-- | python/libxsltclass.txt | 1 | ||||
-rwxr-xr-x | python/tests/basic.py | 3 | ||||
-rwxr-xr-x | python/tests/extfunc.py | 10 |
10 files changed, 643 insertions, 563 deletions
@@ -1,3 +1,11 @@ +Wed Feb 6 23:34:10 CET 2002 Daniel Veillard <daniel@veillard.com> + + * python/libxsl.py python/libxslt-python-api.xml python/libxslt.c + python/libxsltclass.txt: added libxslt_xsltCleanup() added parameters + to libxslt_xsltApplyStylesheet() removed the memleaks left and + fixed an import order. + * python/tests/basic.py python/tests/extfunc.py: updated the tests + Wed Feb 6 19:46:09 CET 2002 Daniel Veillard <daniel@veillard.com> * python/libxlst.c python/libxslt-python-api.xml diff --git a/doc/libxslt-api.xml b/doc/libxslt-api.xml index f8cedc91..6c0be4e6 100644 --- a/doc/libxslt-api.xml +++ b/doc/libxslt-api.xml @@ -31,15 +31,6 @@ <exports symbol='xslAddCall'/> <exports symbol='xslDropCall'/> </file> - <file name='documents'> - <exports symbol='xsltNewDocument'/> - <exports symbol='xsltLoadDocument'/> - <exports symbol='xsltFindDocument'/> - <exports symbol='xsltFreeDocuments'/> - <exports symbol='xsltLoadStyleDocument'/> - <exports symbol='xsltNewStyleDocument'/> - <exports symbol='xsltFreeStyleDocuments'/> - </file> <file name='attributes'> <exports symbol='xsltParseStylesheetAttributeSet'/> <exports symbol='xsltFreeAttributeSetsHashes'/> @@ -102,42 +93,6 @@ <exports symbol='xsltFindElemSpaceHandling'/> <exports symbol='xsltFindTemplate'/> </file> - <file name='libxslt'> - <exports symbol='IN_LIBXSLT'/> - <exports symbol='LIBXSLT_PUBLIC'/> - </file> - <file name='transform'> - <exports symbol='xsltSetXIncludeDefault'/> - <exports symbol='xsltGetXIncludeDefault'/> - <exports symbol='xsltNewTransformContext'/> - <exports symbol='xsltFreeTransformContext'/> - <exports symbol='xsltApplyStylesheetUser'/> - <exports symbol='xsltApplyStripSpaces'/> - <exports symbol='xsltExtElementLookup'/> - <exports symbol='xsltApplyStylesheet'/> - <exports symbol='xsltProfileStylesheet'/> - <exports symbol='xsltRunStylesheet'/> - <exports symbol='xsltApplyOneTemplate'/> - <exports symbol='xsltDocumentElem'/> - <exports symbol='xsltSort'/> - <exports symbol='xsltCopy'/> - <exports symbol='xsltText'/> - <exports symbol='xsltElement'/> - <exports symbol='xsltComment'/> - <exports symbol='xsltAttribute'/> - <exports symbol='xsltProcessingInstruction'/> - <exports symbol='xsltCopyOf'/> - <exports symbol='xsltValueOf'/> - <exports symbol='xsltNumber'/> - <exports symbol='xsltApplyImports'/> - <exports symbol='xsltCallTemplate'/> - <exports symbol='xsltApplyTemplates'/> - <exports symbol='xsltChoose'/> - <exports symbol='xsltIf'/> - <exports symbol='xsltForEach'/> - <exports symbol='xsltRegisterAllElement'/> - <exports symbol='xslHandleDebugger'/> - </file> <file name='xsltInternals'> <exports symbol='XSLT_MAX_SORT'/> <exports symbol='XSLT_PAT_NO_PRIORITY'/> @@ -179,6 +134,51 @@ <exports symbol='xsltFormatNumberConversion'/> <exports symbol='xsltParseTemplateContent'/> </file> + <file name='libxslt'> + <exports symbol='IN_LIBXSLT'/> + <exports symbol='LIBXSLT_PUBLIC'/> + </file> + <file name='transform'> + <exports symbol='xsltSetXIncludeDefault'/> + <exports symbol='xsltGetXIncludeDefault'/> + <exports symbol='xsltNewTransformContext'/> + <exports symbol='xsltFreeTransformContext'/> + <exports symbol='xsltApplyStylesheetUser'/> + <exports symbol='xsltApplyStripSpaces'/> + <exports symbol='xsltExtElementLookup'/> + <exports symbol='xsltApplyStylesheet'/> + <exports symbol='xsltProfileStylesheet'/> + <exports symbol='xsltRunStylesheet'/> + <exports symbol='xsltApplyOneTemplate'/> + <exports symbol='xsltDocumentElem'/> + <exports symbol='xsltSort'/> + <exports symbol='xsltCopy'/> + <exports symbol='xsltText'/> + <exports symbol='xsltElement'/> + <exports symbol='xsltComment'/> + <exports symbol='xsltAttribute'/> + <exports symbol='xsltProcessingInstruction'/> + <exports symbol='xsltCopyOf'/> + <exports symbol='xsltValueOf'/> + <exports symbol='xsltNumber'/> + <exports symbol='xsltApplyImports'/> + <exports symbol='xsltCallTemplate'/> + <exports symbol='xsltApplyTemplates'/> + <exports symbol='xsltChoose'/> + <exports symbol='xsltIf'/> + <exports symbol='xsltForEach'/> + <exports symbol='xsltRegisterAllElement'/> + <exports symbol='xslHandleDebugger'/> + </file> + <file name='documents'> + <exports symbol='xsltNewDocument'/> + <exports symbol='xsltLoadDocument'/> + <exports symbol='xsltFindDocument'/> + <exports symbol='xsltFreeDocuments'/> + <exports symbol='xsltLoadStyleDocument'/> + <exports symbol='xsltNewStyleDocument'/> + <exports symbol='xsltFreeStyleDocuments'/> + </file> <file name='extra'> <exports symbol='XSLT_LIBXSLT_NAMESPACE'/> <exports symbol='XSLT_SAXON_NAMESPACE'/> @@ -703,12 +703,7 @@ <return type='void'/> <arg name='comp' type='xsltElemPreCompPtr' info='the xsltElemPreComp to free up '/> </functype> - <function name='xsltElemPreCompPtr' file='extensions'> - <return type='typedef'/> - <arg name='style' type='*xsltPreComputeFunction) (xsltStylesheetPtr'/> - <arg name='inst' type='xmlNodePtr'/> - <arg name='function' type='xsltTransformFunction'/> - </function> + <typedef name='xsltElemPreCompPtr' file='xsltInternals'/> <function name='xsltElement' file='transform'> <info>Process the xslt element node on the source node</info> <return type='void'/> diff --git a/doc/libxslt-decl.txt b/doc/libxslt-decl.txt index 67b56345..2d2f4e30 100644 --- a/doc/libxslt-decl.txt +++ b/doc/libxslt-decl.txt @@ -28,487 +28,6 @@ void </FUNCTION> <MACRO> -<NAME>XSLT_MAX_SORT</NAME> -#define XSLT_MAX_SORT 5 -</MACRO> -<MACRO> -<NAME>XSLT_PAT_NO_PRIORITY</NAME> -#define XSLT_PAT_NO_PRIORITY -12345789 -</MACRO> -<STRUCT> -<NAME>xsltTemplate</NAME> -</STRUCT> -<TYPEDEF> -<NAME>xsltTemplatePtr</NAME> -typedef xsltTemplate *xsltTemplatePtr; -</TYPEDEF> -<STRUCT> -<NAME>xsltTemplate</NAME> -struct xsltTemplate { - struct _xsltTemplate *next;/* chained list sorted by priority */ - struct _xsltStylesheet *style;/* the containing stylesheet */ - xmlChar *match; /* the matching string */ - float priority; /* as given from the stylesheet, not computed */ - xmlChar *name; /* the local part of the name QName */ - xmlChar *nameURI; /* the URI part of the name QName */ - xmlChar *mode; /* the local part of the mode QName */ - xmlChar *modeURI; /* the URI part of the mode QName */ - xmlNodePtr content; /* the template replacement value */ - xmlNodePtr elem; /* the source element */ - - int inheritedNsNr; /* number of inherited namespaces */ - xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */ - - /* Profiling informations */ - int nbCalls; /* the number of time the template was called */ - unsigned long time; /* the time spent in this template */ -}; -</STRUCT> -<STRUCT> -<NAME>xsltDecimalFormat</NAME> -</STRUCT> -<TYPEDEF> -<NAME>xsltDecimalFormatPtr</NAME> -typedef xsltDecimalFormat *xsltDecimalFormatPtr; -</TYPEDEF> -<STRUCT> -<NAME>xsltDecimalFormat</NAME> -struct xsltDecimalFormat { - struct _xsltDecimalFormat *next; /* chained list */ - xmlChar *name; - /* Used for interpretation of pattern */ - xmlChar *digit; - xmlChar *patternSeparator; - /* May appear in result */ - xmlChar *minusSign; - xmlChar *infinity; - xmlChar *noNumber; /* Not-a-number */ - /* Used for interpretation of pattern and may appear in result */ - xmlChar *decimalPoint; - xmlChar *grouping; - xmlChar *percent; - xmlChar *permille; - xmlChar *zeroDigit; -}; -</STRUCT> -<STRUCT> -<NAME>xsltDocument</NAME> -</STRUCT> -<TYPEDEF> -<NAME>xsltDocumentPtr</NAME> -typedef xsltDocument *xsltDocumentPtr; -</TYPEDEF> -<STRUCT> -<NAME>xsltDocument</NAME> -struct xsltDocument { - struct _xsltDocument *next; /* documents are kept in a chained list */ - int main; /* is this the main document */ - xmlDocPtr doc; /* the parsed document */ - void *keys; /* key tables storage */ -}; -</STRUCT> -<STRUCT> -<NAME>xsltTransformContext</NAME> -</STRUCT> -<TYPEDEF> -<NAME>xsltTransformContextPtr</NAME> -typedef xsltTransformContext *xsltTransformContextPtr; -</TYPEDEF> -<STRUCT> -<NAME>xsltElemPreComp</NAME> -</STRUCT> -<TYPEDEF> -<NAME>xsltElemPreCompPtr</NAME> -typedef xsltElemPreComp *xsltElemPreCompPtr; -</TYPEDEF> -<USER_FUNCTION> -<NAME>xsltTransformFunction</NAME> -<RETURNS>void </RETURNS> -xsltTransformContextPtr ctxt, - xmlNodePtr node, - xmlNodePtr inst, - xsltElemPreCompPtr comp -</USER_FUNCTION> -<ENUM> -<NAME>xsltStyleType</NAME> -typedef enum { - XSLT_FUNC_COPY=1, - XSLT_FUNC_SORT, - XSLT_FUNC_TEXT, - XSLT_FUNC_ELEMENT, - XSLT_FUNC_ATTRIBUTE, - XSLT_FUNC_COMMENT, - XSLT_FUNC_PI, - XSLT_FUNC_COPYOF, - XSLT_FUNC_VALUEOF, - XSLT_FUNC_NUMBER, - XSLT_FUNC_APPLYIMPORTS, - XSLT_FUNC_CALLTEMPLATE, - XSLT_FUNC_APPLYTEMPLATES, - XSLT_FUNC_CHOOSE, - XSLT_FUNC_IF, - XSLT_FUNC_FOREACH, - XSLT_FUNC_DOCUMENT, - XSLT_FUNC_WITHPARAM, - XSLT_FUNC_PARAM, - XSLT_FUNC_VARIABLE, - XSLT_FUNC_WHEN, - XSLT_FUNC_EXTENSION -} xsltStyleType; -</ENUM> -<USER_FUNCTION> -<NAME>xsltElemPreCompDeallocator</NAME> -<RETURNS>void </RETURNS> -xsltElemPreCompPtr comp -</USER_FUNCTION> -<STRUCT> -<NAME>xsltElemPreComp</NAME> -struct xsltElemPreComp { - xsltElemPreCompPtr next; /* chained list */ - xsltStyleType type; /* type of the element */ - xsltTransformFunction func; /* handling function */ - xmlNodePtr inst; /* the instruction */ - - /* end of common part */ - xsltElemPreCompDeallocator free; /* the deallocator */ -}; -</STRUCT> -<STRUCT> -<NAME>xsltStylePreComp</NAME> -</STRUCT> -<TYPEDEF> -<NAME>xsltStylePreCompPtr</NAME> -typedef xsltStylePreComp *xsltStylePreCompPtr; -</TYPEDEF> -<STRUCT> -<NAME>xsltStylePreComp</NAME> -struct xsltStylePreComp { - xsltElemPreCompPtr next; /* chained list */ - xsltStyleType type; /* type of the element */ - xsltTransformFunction func; /* handling function */ - xmlNodePtr inst; /* the instruction */ - - /* - * Pre computed values - */ - - xmlChar *stype; /* sort */ - int has_stype; /* sort */ - int number; /* sort */ - xmlChar *order; /* sort */ - int has_order; /* sort */ - int descending; /* sort */ - - xmlChar *use; /* copy, element */ - int has_use; /* copy, element */ - - int noescape; /* text */ - - xmlChar *name; /* element, attribute, pi */ - int has_name; /* element, attribute, pi */ - xmlChar *ns; /* element */ - int has_ns; /* element */ - - xmlChar *mode; /* apply-templates */ - xmlChar *modeURI; /* apply-templates */ - - xmlChar *test; /* if */ - - xsltTemplatePtr templ; /* call-template */ - - xmlChar *select; /* sort, copy-of, value-of, apply-templates */ - - int ver11; /* document */ - xmlChar *filename; /* document URL */ - int has_filename; /* document */ - - xsltNumberData numdata; /* number */ - - xmlXPathCompExprPtr comp; /* a precompiled XPath expression */ - xmlNsPtr *nsList; /* the namespaces in scope */ - int nsNr; /* the number of namespaces in scope */ -}; -</STRUCT> -<STRUCT> -<NAME>xsltStackElem</NAME> -</STRUCT> -<TYPEDEF> -<NAME>xsltStackElemPtr</NAME> -typedef xsltStackElem *xsltStackElemPtr; -</TYPEDEF> -<STRUCT> -<NAME>xsltStackElem</NAME> -struct xsltStackElem { - struct _xsltStackElem *next;/* chained list */ - xsltStylePreCompPtr comp; /* the compiled form */ - int computed; /* was the evaluation done */ - xmlChar *name; /* the local part of the name QName */ - xmlChar *nameURI; /* the URI part of the name QName */ - xmlChar *select; /* the eval string */ - xmlNodePtr tree; /* the tree if no eval string or the location */ - xmlXPathObjectPtr value; /* The value if computed */ -}; -</STRUCT> -<STRUCT> -<NAME>xsltStylesheet</NAME> -</STRUCT> -<TYPEDEF> -<NAME>xsltStylesheetPtr</NAME> -typedef xsltStylesheet *xsltStylesheetPtr; -</TYPEDEF> -<STRUCT> -<NAME>xsltStylesheet</NAME> -struct xsltStylesheet { - /* - * The stylesheet import relation is kept as a tree - */ - struct _xsltStylesheet *parent; - struct _xsltStylesheet *next; - struct _xsltStylesheet *imports; - - xsltDocumentPtr docList; /* the include document list */ - - /* - * General data on the style sheet document - */ - xmlDocPtr doc; /* the parsed XML stylesheet */ - xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and - preserve space elements */ - int stripAll; /* strip-space * (1) preserve-space * (-1) */ - xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */ - - /* - * Global variable or parameters - */ - xsltStackElemPtr variables; /* linked list of param and variables */ - - /* - * Template descriptions - */ - xsltTemplatePtr templates; /* the ordered list of templates */ - void *templatesHash; /* hash table or wherever compiled templates - informations are stored */ - void *rootMatch; /* template based on / */ - void *keyMatch; /* template based on key() */ - void *elemMatch; /* template based on * */ - void *attrMatch; /* template based on @* */ - void *parentMatch; /* template based on .. */ - void *textMatch; /* template based on text() */ - void *piMatch; /* template based on processing-instruction() */ - void *commentMatch; /* template based on comment() */ - - /* - * Namespace aliases - */ - xmlHashTablePtr nsAliases; /* the namespace alias hash tables */ - - /* - * Attribute sets - */ - xmlHashTablePtr attributeSets;/* the attribute sets hash tables */ - - /* - * Namespaces - */ - xmlHashTablePtr nsHash; /* the set of namespaces in use */ - void *nsDefs; /* the namespaces defined */ - - /* - * Key definitions - */ - void *keys; /* key definitions */ - - /* - * Output related stuff. - */ - xmlChar *method; /* the output method */ - xmlChar *methodURI; /* associated namespace if any */ - xmlChar *version; /* version string */ - xmlChar *encoding; /* encoding string */ - int omitXmlDeclaration; /* omit-xml-declaration = "yes" | "no" */ - - /* Number formatting */ - xsltDecimalFormatPtr decimalFormat; - int standalone; /* standalone = "yes" | "no" */ - xmlChar *doctypePublic; /* doctype-public string */ - xmlChar *doctypeSystem; /* doctype-system string */ - int indent; /* should output being indented */ - xmlChar *mediaType; /* media-type string */ - - /* - * Precomputed blocks - */ - xsltElemPreCompPtr preComps;/* list of precomputed blocks */ - int warnings; /* number of warnings found at compilation */ - int errors; /* number of errors found at compilation */ - - xmlChar *exclPrefix; /* last excluded prefixes */ - xmlChar **exclPrefixTab; /* array of excluded prefixes */ - int exclPrefixNr; /* number of excluded prefixes in scope */ - int exclPrefixMax; /* size of the array */ - - void *_private; /* user defined data */ - - /* - * Extensions - */ - xmlHashTablePtr extInfos; /* the extension data */ -}; -</STRUCT> -<ENUM> -<NAME>xsltOutputType</NAME> -typedef enum { - XSLT_OUTPUT_XML = 0, - XSLT_OUTPUT_HTML, - XSLT_OUTPUT_TEXT -} xsltOutputType; -</ENUM> -<ENUM> -<NAME>xsltTransformState</NAME> -typedef enum { - XSLT_STATE_OK = 0, - XSLT_STATE_ERROR, - XSLT_STATE_STOPPED -} xsltTransformState; -</ENUM> -<STRUCT> -<NAME>xsltTransformContext</NAME> -struct xsltTransformContext { - xsltStylesheetPtr style; /* the stylesheet used */ - xsltOutputType type; /* the type of output */ - - xsltTemplatePtr templ; /* the current template */ - int templNr; /* Nb of templates in the stack */ - int templMax; /* Size of the templtes stack */ - xsltTemplatePtr *templTab; /* the template stack */ - - xsltStackElemPtr vars; /* the current variable list */ - int varsNr; /* Nb of variable list in the stack */ - int varsMax; /* Size of the variable list stack */ - xsltStackElemPtr *varsTab; /* the variable list stack */ - int varsBase; /* the var base for current templ */ - - /* - * Extensions - */ - xmlHashTablePtr extFunctions; /* the extension functions */ - xmlHashTablePtr extElements; /* the extension elements */ - xmlHashTablePtr extInfos; /* the extension data */ - - const xmlChar *mode; /* the current mode */ - const xmlChar *modeURI; /* the current mode URI */ - - xsltDocumentPtr docList; /* the document list */ - - xsltDocumentPtr document; /* the current document */ - xmlNodePtr node; /* the current node being processed */ - xmlNodeSetPtr nodeList; /* the current node list */ - /* xmlNodePtr current; the node */ - - xmlDocPtr output; /* the resulting document */ - xmlNodePtr insert; /* the insertion node */ - - xmlXPathContextPtr xpathCtxt; /* the XPath context */ - xsltTransformState state; /* the current state */ - - /* - * Global variables - */ - xmlHashTablePtr globalVars; /* the global variables and params */ - - xmlNodePtr inst; /* the instruction in the stylesheet */ - - int xinclude; /* should XInclude be processed */ - - const char * outputFile; /* the output URI if known */ - - int profile; /* is this run profiled */ - long prof; /* the current profiled value */ - int profNr; /* Nb of templates in the stack */ - int profMax; /* Size of the templtaes stack */ - long *profTab; /* the profile template stack */ - - void *_private; /* user defined data */ -}; -</STRUCT> -<MACRO> -<NAME>CHECK_STOPPED</NAME> -#define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return; -</MACRO> -<MACRO> -<NAME>CHECK_STOPPEDE</NAME> -#define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error; -</MACRO> -<MACRO> -<NAME>CHECK_STOPPED0</NAME> -#define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0); -</MACRO> -<FUNCTION> -<NAME>xsltNewStylesheet</NAME> -<RETURNS>xsltStylesheetPtr </RETURNS> -void -</FUNCTION> -<FUNCTION> -<NAME>xsltParseStylesheetFile</NAME> -<RETURNS>xsltStylesheetPtr </RETURNS> -const xmlChar* filename -</FUNCTION> -<FUNCTION> -<NAME>xsltFreeStylesheet</NAME> -<RETURNS>void </RETURNS> -xsltStylesheetPtr sheet -</FUNCTION> -<FUNCTION> -<NAME>xsltIsBlank</NAME> -<RETURNS>int </RETURNS> -xmlChar *str -</FUNCTION> -<FUNCTION> -<NAME>xsltFreeStackElemList</NAME> -<RETURNS>void </RETURNS> -xsltStackElemPtr elem -</FUNCTION> -<FUNCTION> -<NAME>xsltDecimalFormatGetByName</NAME> -<RETURNS>xsltDecimalFormatPtr </RETURNS> -xsltStylesheetPtr sheet,xmlChar *name -</FUNCTION> -<FUNCTION> -<NAME>xsltParseStylesheetProcess</NAME> -<RETURNS>xsltStylesheetPtr </RETURNS> -xsltStylesheetPtr ret,xmlDocPtr doc -</FUNCTION> -<FUNCTION> -<NAME>xsltParseStylesheetOutput</NAME> -<RETURNS>void </RETURNS> -xsltStylesheetPtr style,xmlNodePtr cur -</FUNCTION> -<FUNCTION> -<NAME>xsltParseStylesheetDoc</NAME> -<RETURNS>xsltStylesheetPtr </RETURNS> -xmlDocPtr doc -</FUNCTION> -<FUNCTION> -<NAME>xsltLoadStylesheetPI</NAME> -<RETURNS>xsltStylesheetPtr </RETURNS> -xmlDocPtr doc -</FUNCTION> -<FUNCTION> -<NAME>xsltNumberFormat</NAME> -<RETURNS>void </RETURNS> -xsltTransformContextPtr ctxt,xsltNumberDataPtr data,xmlNodePtr node -</FUNCTION> -<FUNCTION> -<NAME>xsltFormatNumberConversion</NAME> -<RETURNS>xmlXPathError </RETURNS> -xsltDecimalFormatPtr self,xmlChar *format,double number,xmlChar **result -</FUNCTION> -<FUNCTION> -<NAME>xsltParseTemplateContent</NAME> -<RETURNS>void </RETURNS> -xsltStylesheetPtr style,xmlNodePtr templ -</FUNCTION> -<MACRO> <NAME>LIBXSLT_DOTTED_VERSION</NAME> #define LIBXSLT_DOTTED_VERSION "1.0.10" </MACRO> @@ -1546,3 +1065,484 @@ xsltStylesheetPtr style <NAME>LIBXSLT_PUBLIC</NAME> #define LIBXSLT_PUBLIC </MACRO> +<MACRO> +<NAME>XSLT_MAX_SORT</NAME> +#define XSLT_MAX_SORT 5 +</MACRO> +<MACRO> +<NAME>XSLT_PAT_NO_PRIORITY</NAME> +#define XSLT_PAT_NO_PRIORITY -12345789 +</MACRO> +<STRUCT> +<NAME>xsltTemplate</NAME> +</STRUCT> +<TYPEDEF> +<NAME>xsltTemplatePtr</NAME> +typedef xsltTemplate *xsltTemplatePtr; +</TYPEDEF> +<STRUCT> +<NAME>xsltTemplate</NAME> +struct xsltTemplate { + struct _xsltTemplate *next;/* chained list sorted by priority */ + struct _xsltStylesheet *style;/* the containing stylesheet */ + xmlChar *match; /* the matching string */ + float priority; /* as given from the stylesheet, not computed */ + xmlChar *name; /* the local part of the name QName */ + xmlChar *nameURI; /* the URI part of the name QName */ + xmlChar *mode; /* the local part of the mode QName */ + xmlChar *modeURI; /* the URI part of the mode QName */ + xmlNodePtr content; /* the template replacement value */ + xmlNodePtr elem; /* the source element */ + + int inheritedNsNr; /* number of inherited namespaces */ + xmlNsPtr *inheritedNs;/* inherited non-excluded namespaces */ + + /* Profiling informations */ + int nbCalls; /* the number of time the template was called */ + unsigned long time; /* the time spent in this template */ +}; +</STRUCT> +<STRUCT> +<NAME>xsltDecimalFormat</NAME> +</STRUCT> +<TYPEDEF> +<NAME>xsltDecimalFormatPtr</NAME> +typedef xsltDecimalFormat *xsltDecimalFormatPtr; +</TYPEDEF> +<STRUCT> +<NAME>xsltDecimalFormat</NAME> +struct xsltDecimalFormat { + struct _xsltDecimalFormat *next; /* chained list */ + xmlChar *name; + /* Used for interpretation of pattern */ + xmlChar *digit; + xmlChar *patternSeparator; + /* May appear in result */ + xmlChar *minusSign; + xmlChar *infinity; + xmlChar *noNumber; /* Not-a-number */ + /* Used for interpretation of pattern and may appear in result */ + xmlChar *decimalPoint; + xmlChar *grouping; + xmlChar *percent; + xmlChar *permille; + xmlChar *zeroDigit; +}; +</STRUCT> +<STRUCT> +<NAME>xsltDocument</NAME> +</STRUCT> +<TYPEDEF> +<NAME>xsltDocumentPtr</NAME> +typedef xsltDocument *xsltDocumentPtr; +</TYPEDEF> +<STRUCT> +<NAME>xsltDocument</NAME> +struct xsltDocument { + struct _xsltDocument *next; /* documents are kept in a chained list */ + int main; /* is this the main document */ + xmlDocPtr doc; /* the parsed document */ + void *keys; /* key tables storage */ +}; +</STRUCT> +<STRUCT> +<NAME>xsltTransformContext</NAME> +</STRUCT> +<TYPEDEF> +<NAME>xsltTransformContextPtr</NAME> +typedef xsltTransformContext *xsltTransformContextPtr; +</TYPEDEF> +<STRUCT> +<NAME>xsltElemPreComp</NAME> +</STRUCT> +<TYPEDEF> +<NAME>xsltElemPreCompPtr</NAME> +typedef xsltElemPreComp *xsltElemPreCompPtr; +</TYPEDEF> +<USER_FUNCTION> +<NAME>xsltTransformFunction</NAME> +<RETURNS>void </RETURNS> +xsltTransformContextPtr ctxt, + xmlNodePtr node, + xmlNodePtr inst, + xsltElemPreCompPtr comp +</USER_FUNCTION> +<ENUM> +<NAME>xsltStyleType</NAME> +typedef enum { + XSLT_FUNC_COPY=1, + XSLT_FUNC_SORT, + XSLT_FUNC_TEXT, + XSLT_FUNC_ELEMENT, + XSLT_FUNC_ATTRIBUTE, + XSLT_FUNC_COMMENT, + XSLT_FUNC_PI, + XSLT_FUNC_COPYOF, + XSLT_FUNC_VALUEOF, + XSLT_FUNC_NUMBER, + XSLT_FUNC_APPLYIMPORTS, + XSLT_FUNC_CALLTEMPLATE, + XSLT_FUNC_APPLYTEMPLATES, + XSLT_FUNC_CHOOSE, + XSLT_FUNC_IF, + XSLT_FUNC_FOREACH, + XSLT_FUNC_DOCUMENT, + XSLT_FUNC_WITHPARAM, + XSLT_FUNC_PARAM, + XSLT_FUNC_VARIABLE, + XSLT_FUNC_WHEN, + XSLT_FUNC_EXTENSION +} xsltStyleType; +</ENUM> +<USER_FUNCTION> +<NAME>xsltElemPreCompDeallocator</NAME> +<RETURNS>void </RETURNS> +xsltElemPreCompPtr comp +</USER_FUNCTION> +<STRUCT> +<NAME>xsltElemPreComp</NAME> +struct xsltElemPreComp { + xsltElemPreCompPtr next; /* chained list */ + xsltStyleType type; /* type of the element */ + xsltTransformFunction func; /* handling function */ + xmlNodePtr inst; /* the instruction */ + + /* end of common part */ + xsltElemPreCompDeallocator free; /* the deallocator */ +}; +</STRUCT> +<STRUCT> +<NAME>xsltStylePreComp</NAME> +</STRUCT> +<TYPEDEF> +<NAME>xsltStylePreCompPtr</NAME> +typedef xsltStylePreComp *xsltStylePreCompPtr; +</TYPEDEF> +<STRUCT> +<NAME>xsltStylePreComp</NAME> +struct xsltStylePreComp { + xsltElemPreCompPtr next; /* chained list */ + xsltStyleType type; /* type of the element */ + xsltTransformFunction func; /* handling function */ + xmlNodePtr inst; /* the instruction */ + + /* + * Pre computed values + */ + + xmlChar *stype; /* sort */ + int has_stype; /* sort */ + int number; /* sort */ + xmlChar *order; /* sort */ + int has_order; /* sort */ + int descending; /* sort */ + + xmlChar *use; /* copy, element */ + int has_use; /* copy, element */ + + int noescape; /* text */ + + xmlChar *name; /* element, attribute, pi */ + int has_name; /* element, attribute, pi */ + xmlChar *ns; /* element */ + int has_ns; /* element */ + + xmlChar *mode; /* apply-templates */ + xmlChar *modeURI; /* apply-templates */ + + xmlChar *test; /* if */ + + xsltTemplatePtr templ; /* call-template */ + + xmlChar *select; /* sort, copy-of, value-of, apply-templates */ + + int ver11; /* document */ + xmlChar *filename; /* document URL */ + int has_filename; /* document */ + + xsltNumberData numdata; /* number */ + + xmlXPathCompExprPtr comp; /* a precompiled XPath expression */ + xmlNsPtr *nsList; /* the namespaces in scope */ + int nsNr; /* the number of namespaces in scope */ +}; +</STRUCT> +<STRUCT> +<NAME>xsltStackElem</NAME> +</STRUCT> +<TYPEDEF> +<NAME>xsltStackElemPtr</NAME> +typedef xsltStackElem *xsltStackElemPtr; +</TYPEDEF> +<STRUCT> +<NAME>xsltStackElem</NAME> +struct xsltStackElem { + struct _xsltStackElem *next;/* chained list */ + xsltStylePreCompPtr comp; /* the compiled form */ + int computed; /* was the evaluation done */ + xmlChar *name; /* the local part of the name QName */ + xmlChar *nameURI; /* the URI part of the name QName */ + xmlChar *select; /* the eval string */ + xmlNodePtr tree; /* the tree if no eval string or the location */ + xmlXPathObjectPtr value; /* The value if computed */ +}; +</STRUCT> +<STRUCT> +<NAME>xsltStylesheet</NAME> +</STRUCT> +<TYPEDEF> +<NAME>xsltStylesheetPtr</NAME> +typedef xsltStylesheet *xsltStylesheetPtr; +</TYPEDEF> +<STRUCT> +<NAME>xsltStylesheet</NAME> +struct xsltStylesheet { + /* + * The stylesheet import relation is kept as a tree + */ + struct _xsltStylesheet *parent; + struct _xsltStylesheet *next; + struct _xsltStylesheet *imports; + + xsltDocumentPtr docList; /* the include document list */ + + /* + * General data on the style sheet document + */ + xmlDocPtr doc; /* the parsed XML stylesheet */ + xmlHashTablePtr stripSpaces;/* the hash table of the strip-space and + preserve space elements */ + int stripAll; /* strip-space * (1) preserve-space * (-1) */ + xmlHashTablePtr cdataSection;/* the hash table of the cdata-section */ + + /* + * Global variable or parameters + */ + xsltStackElemPtr variables; /* linked list of param and variables */ + + /* + * Template descriptions + */ + xsltTemplatePtr templates; /* the ordered list of templates */ + void *templatesHash; /* hash table or wherever compiled templates + informations are stored */ + void *rootMatch; /* template based on / */ + void *keyMatch; /* template based on key() */ + void *elemMatch; /* template based on * */ + void *attrMatch; /* template based on @* */ + void *parentMatch; /* template based on .. */ + void *textMatch; /* template based on text() */ + void *piMatch; /* template based on processing-instruction() */ + void *commentMatch; /* template based on comment() */ + + /* + * Namespace aliases + */ + xmlHashTablePtr nsAliases; /* the namespace alias hash tables */ + + /* + * Attribute sets + */ + xmlHashTablePtr attributeSets;/* the attribute sets hash tables */ + + /* + * Namespaces + */ + xmlHashTablePtr nsHash; /* the set of namespaces in use */ + void *nsDefs; /* the namespaces defined */ + + /* + * Key definitions + */ + void *keys; /* key definitions */ + + /* + * Output related stuff. + */ + xmlChar *method; /* the output method */ + xmlChar *methodURI; /* associated namespace if any */ + xmlChar *version; /* version string */ + xmlChar *encoding; /* encoding string */ + int omitXmlDeclaration; /* omit-xml-declaration = "yes" | "no" */ + + /* Number formatting */ + xsltDecimalFormatPtr decimalFormat; + int standalone; /* standalone = "yes" | "no" */ + xmlChar *doctypePublic; /* doctype-public string */ + xmlChar *doctypeSystem; /* doctype-system string */ + int indent; /* should output being indented */ + xmlChar *mediaType; /* media-type string */ + + /* + * Precomputed blocks + */ + xsltElemPreCompPtr preComps;/* list of precomputed blocks */ + int warnings; /* number of warnings found at compilation */ + int errors; /* number of errors found at compilation */ + + xmlChar *exclPrefix; /* last excluded prefixes */ + xmlChar **exclPrefixTab; /* array of excluded prefixes */ + int exclPrefixNr; /* number of excluded prefixes in scope */ + int exclPrefixMax; /* size of the array */ + + void *_private; /* user defined data */ + + /* + * Extensions + */ + xmlHashTablePtr extInfos; /* the extension data */ +}; +</STRUCT> +<ENUM> +<NAME>xsltOutputType</NAME> +typedef enum { + XSLT_OUTPUT_XML = 0, + XSLT_OUTPUT_HTML, + XSLT_OUTPUT_TEXT +} xsltOutputType; +</ENUM> +<ENUM> +<NAME>xsltTransformState</NAME> +typedef enum { + XSLT_STATE_OK = 0, + XSLT_STATE_ERROR, + XSLT_STATE_STOPPED +} xsltTransformState; +</ENUM> +<STRUCT> +<NAME>xsltTransformContext</NAME> +struct xsltTransformContext { + xsltStylesheetPtr style; /* the stylesheet used */ + xsltOutputType type; /* the type of output */ + + xsltTemplatePtr templ; /* the current template */ + int templNr; /* Nb of templates in the stack */ + int templMax; /* Size of the templtes stack */ + xsltTemplatePtr *templTab; /* the template stack */ + + xsltStackElemPtr vars; /* the current variable list */ + int varsNr; /* Nb of variable list in the stack */ + int varsMax; /* Size of the variable list stack */ + xsltStackElemPtr *varsTab; /* the variable list stack */ + int varsBase; /* the var base for current templ */ + + /* + * Extensions + */ + xmlHashTablePtr extFunctions; /* the extension functions */ + xmlHashTablePtr extElements; /* the extension elements */ + xmlHashTablePtr extInfos; /* the extension data */ + + const xmlChar *mode; /* the current mode */ + const xmlChar *modeURI; /* the current mode URI */ + + xsltDocumentPtr docList; /* the document list */ + + xsltDocumentPtr document; /* the current document */ + xmlNodePtr node; /* the current node being processed */ + xmlNodeSetPtr nodeList; /* the current node list */ + /* xmlNodePtr current; the node */ + + xmlDocPtr output; /* the resulting document */ + xmlNodePtr insert; /* the insertion node */ + + xmlXPathContextPtr xpathCtxt; /* the XPath context */ + xsltTransformState state; /* the current state */ + + /* + * Global variables + */ + xmlHashTablePtr globalVars; /* the global variables and params */ + + xmlNodePtr inst; /* the instruction in the stylesheet */ + + int xinclude; /* should XInclude be processed */ + + const char * outputFile; /* the output URI if known */ + + int profile; /* is this run profiled */ + long prof; /* the current profiled value */ + int profNr; /* Nb of templates in the stack */ + int profMax; /* Size of the templtaes stack */ + long *profTab; /* the profile template stack */ + + void *_private; /* user defined data */ +}; +</STRUCT> +<MACRO> +<NAME>CHECK_STOPPED</NAME> +#define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return; +</MACRO> +<MACRO> +<NAME>CHECK_STOPPEDE</NAME> +#define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error; +</MACRO> +<MACRO> +<NAME>CHECK_STOPPED0</NAME> +#define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0); +</MACRO> +<FUNCTION> +<NAME>xsltNewStylesheet</NAME> +<RETURNS>xsltStylesheetPtr </RETURNS> +void +</FUNCTION> +<FUNCTION> +<NAME>xsltParseStylesheetFile</NAME> +<RETURNS>xsltStylesheetPtr </RETURNS> +const xmlChar* filename +</FUNCTION> +<FUNCTION> +<NAME>xsltFreeStylesheet</NAME> +<RETURNS>void </RETURNS> +xsltStylesheetPtr sheet +</FUNCTION> +<FUNCTION> +<NAME>xsltIsBlank</NAME> +<RETURNS>int </RETURNS> +xmlChar *str +</FUNCTION> +<FUNCTION> +<NAME>xsltFreeStackElemList</NAME> +<RETURNS>void </RETURNS> +xsltStackElemPtr elem +</FUNCTION> +<FUNCTION> +<NAME>xsltDecimalFormatGetByName</NAME> +<RETURNS>xsltDecimalFormatPtr </RETURNS> +xsltStylesheetPtr sheet,xmlChar *name +</FUNCTION> +<FUNCTION> +<NAME>xsltParseStylesheetProcess</NAME> +<RETURNS>xsltStylesheetPtr </RETURNS> +xsltStylesheetPtr ret,xmlDocPtr doc +</FUNCTION> +<FUNCTION> +<NAME>xsltParseStylesheetOutput</NAME> +<RETURNS>void </RETURNS> +xsltStylesheetPtr style,xmlNodePtr cur +</FUNCTION> +<FUNCTION> +<NAME>xsltParseStylesheetDoc</NAME> +<RETURNS>xsltStylesheetPtr </RETURNS> +xmlDocPtr doc +</FUNCTION> +<FUNCTION> +<NAME>xsltLoadStylesheetPI</NAME> +<RETURNS>xsltStylesheetPtr </RETURNS> +xmlDocPtr doc +</FUNCTION> +<FUNCTION> +<NAME>xsltNumberFormat</NAME> +<RETURNS>void </RETURNS> +xsltTransformContextPtr ctxt,xsltNumberDataPtr data,xmlNodePtr node +</FUNCTION> +<FUNCTION> +<NAME>xsltFormatNumberConversion</NAME> +<RETURNS>xmlXPathError </RETURNS> +xsltDecimalFormatPtr self,xmlChar *format,double number,xmlChar **result +</FUNCTION> +<FUNCTION> +<NAME>xsltParseTemplateContent</NAME> +<RETURNS>void </RETURNS> +xsltStylesheetPtr style,xmlNodePtr templ +</FUNCTION> diff --git a/doc/libxslt-refs.xml b/doc/libxslt-refs.xml index 520a3e30..3dea1054 100644 --- a/doc/libxslt-refs.xml +++ b/doc/libxslt-refs.xml @@ -566,12 +566,12 @@ <ref name='xsltParseStylesheetCallerParam'/> </type> <type name='xsltStylesheetPtr'> + <ref name='xsltNextImport'/> <ref name='xsltNewStylesheet'/> <ref name='xsltParseStylesheetFile'/> <ref name='xsltParseStylesheetProcess'/> <ref name='xsltParseStylesheetDoc'/> <ref name='xsltLoadStylesheetPI'/> - <ref name='xsltNextImport'/> </type> <type name='xsltTemplatePtr'> <ref name='xsltGetTemplate'/> @@ -686,8 +686,8 @@ <ref name='xsltLoadStyleDocument'/> </type> <type name='const xmlChar*'> - <ref name='xsltParseStylesheetFile'/> <ref name='xsltAttrTemplateValueProcess'/> + <ref name='xsltParseStylesheetFile'/> </type> <type name='double'> <ref name='xsltFormatNumberConversion'/> @@ -711,19 +711,16 @@ <ref name='xsltAttrTemplateProcess'/> </type> <type name='xmlChar *'> + <ref name='xsltApplyAttributeSet'/> <ref name='xsltIsBlank'/> <ref name='xsltDecimalFormatGetByName'/> <ref name='xsltFormatNumberConversion'/> - <ref name='xsltApplyAttributeSet'/> </type> <type name='xmlChar **'> - <ref name='xsltFormatNumberConversion'/> <ref name='xsltGetQNameURI'/> + <ref name='xsltFormatNumberConversion'/> </type> <type name='xmlDocPtr'> - <ref name='xsltParseStylesheetProcess'/> - <ref name='xsltParseStylesheetDoc'/> - <ref name='xsltLoadStylesheetPI'/> <ref name='xsltCompilePattern'/> <ref name='xsltMatchPattern'/> <ref name='xsltNewTransformContext'/> @@ -738,17 +735,15 @@ <ref name='xsltNewDocument'/> <ref name='xsltFindDocument'/> <ref name='xsltNewStyleDocument'/> + <ref name='xsltParseStylesheetProcess'/> + <ref name='xsltParseStylesheetDoc'/> + <ref name='xsltLoadStylesheetPI'/> </type> <type name='xmlGenericErrorFunc'> <ref name='xsltSetGenericErrorFunc'/> <ref name='xsltSetGenericDebugFunc'/> </type> <type name='xmlNodePtr'> - <ref name='xsltTransformFunction'/> - <ref name='xsltTransformFunction'/> - <ref name='xsltParseStylesheetOutput'/> - <ref name='xsltNumberFormat'/> - <ref name='xsltParseTemplateContent'/> <ref name='xsltAddKey'/> <ref name='xsltCompilePattern'/> <ref name='xsltTestCompMatchList'/> @@ -837,6 +832,11 @@ <ref name='xsltDebug'/> <ref name='xsltDocumentComp'/> <ref name='xsltStylePreCompute'/> + <ref name='xsltTransformFunction'/> + <ref name='xsltTransformFunction'/> + <ref name='xsltParseStylesheetOutput'/> + <ref name='xsltNumberFormat'/> + <ref name='xsltParseTemplateContent'/> </type> <type name='xmlNodePtr *'> <ref name='xsltDoSortFunction'/> @@ -897,9 +897,9 @@ <ref name='xsltInitElemPreComp'/> </type> <type name='xsltElemPreCompPtr'> + <ref name='xsltInitElemPreComp'/> <ref name='xsltTransformFunction'/> <ref name='xsltElemPreCompDeallocator'/> - <ref name='xsltInitElemPreComp'/> </type> <type name='xsltExtInitFunction'> <ref name='xsltRegisterExtModule'/> @@ -916,9 +916,9 @@ <ref name='xsltRegisterExtModuleElement'/> </type> <type name='xsltStackElemPtr'> - <ref name='xsltFreeStackElemList'/> <ref name='xsltApplyOneTemplate'/> <ref name='xsltAddStackElemList'/> + <ref name='xsltFreeStackElemList'/> </type> <type name='xsltStyleExtInitFunction'> <ref name='xsltRegisterExtModuleFull'/> @@ -947,11 +947,6 @@ <ref name='xsltDebug'/> </type> <type name='xsltStylesheetPtr'> - <ref name='xsltFreeStylesheet'/> - <ref name='xsltDecimalFormatGetByName'/> - <ref name='xsltParseStylesheetProcess'/> - <ref name='xsltParseStylesheetOutput'/> - <ref name='xsltParseTemplateContent'/> <ref name='xsltAddKey'/> <ref name='xsltFreeKeys'/> <ref name='xsltAddTemplate'/> @@ -994,6 +989,11 @@ <ref name='xsltDocumentComp'/> <ref name='xsltStylePreCompute'/> <ref name='xsltFreeStylePreComps'/> + <ref name='xsltFreeStylesheet'/> + <ref name='xsltDecimalFormatGetByName'/> + <ref name='xsltParseStylesheetProcess'/> + <ref name='xsltParseStylesheetOutput'/> + <ref name='xsltParseTemplateContent'/> </type> <type name='xsltTemplatePtr'> <ref name='xsltAddTemplate'/> @@ -1007,8 +1007,6 @@ <ref name='xsltRegisterExtModuleTopLevel'/> </type> <type name='xsltTransformContextPtr'> - <ref name='xsltTransformFunction'/> - <ref name='xsltNumberFormat'/> <ref name='xsltGetKey'/> <ref name='xsltInitCtxtKeys'/> <ref name='xsltTestCompMatchList'/> @@ -1086,6 +1084,8 @@ <ref name='xsltFreeDocuments'/> <ref name='xsltDebug'/> <ref name='xsltRegisterExtras'/> + <ref name='xsltTransformFunction'/> + <ref name='xsltNumberFormat'/> </type> <type name='xsltTransformFunction'> <ref name='xsltElemPreCompPtr'/> diff --git a/python/libxsl.py b/python/libxsl.py index 1ac305fd..85f24ddc 100644 --- a/python/libxsl.py +++ b/python/libxsl.py @@ -1,3 +1,4 @@ +import _libxml import _libxslt from libxml2 import * diff --git a/python/libxslt-python-api.xml b/python/libxslt-python-api.xml index 6ef7a1b5..03a02f20 100644 --- a/python/libxslt-python-api.xml +++ b/python/libxslt-python-api.xml @@ -19,6 +19,10 @@ <arg name='URI' type='xmlChar *' info='the namespace or NULL'/> <arg name='f' type='pythonObject' info='the python function'/> </function> + <function name='xsltCleanup' file='python'> + <info>Cleanup all libxslt and libxml2 memory allocated</info> + <return type='void'/> + </function> <!-- <function name='xsltRegisterXPathFunction' file='python'> <info>Register a Python written function to the XPath interpreter</info> diff --git a/python/libxslt.c b/python/libxslt.c index 7d4af40d..f93dcf1e 100644 --- a/python/libxslt.c +++ b/python/libxslt.c @@ -227,6 +227,7 @@ libxslt_xsltRegisterExtModuleFunction(PyObject *self, PyObject *args) { py_retval = libxml_intWrap(-1); return(py_retval); } + Py_XINCREF(pyobj_f); ret = xsltRegisterExtModuleFunction(name, ns_uri, libxslt_xmlXPathFuncCallback); @@ -234,6 +235,17 @@ libxslt_xsltRegisterExtModuleFunction(PyObject *self, PyObject *args) { return(py_retval); } +void +deallocateCallback(void *payload, xmlChar *name) { + PyObject *function = (PyObject *) payload; + +#ifdef DEBUG_XPATH + printf("deallocateCallback(%s) called\n", name); +#endif + + Py_XDECREF(function); +} + /************************************************************************ * * * Some customized front-ends * @@ -250,14 +262,49 @@ libxslt_xsltApplyStylesheet(PyObject *self, PyObject *args) { PyObject *pyobj_doc; PyObject *pyobj_params; const char **params; + int len = 0, i = 0, j; + PyObject *name; + PyObject *value; 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); + if (PyDict_Check(pyobj_params)) { + len = PyDict_Size(pyobj_params); + if (len > 0) { + params = (const char **) xmlMalloc((len + 1) * 2 * + sizeof(char *)); + if (params == NULL) { + printf("libxslt_xsltApplyStylesheet: out of memory\n"); + Py_INCREF(Py_None); + return(Py_None); + } + j = 0; + while (PyDict_Next(pyobj_params, &i, &name, &value)) { + const char *tmp; + int size; + + tmp = PyString_AS_STRING(name); + size = PyString_GET_SIZE(name); + params[j * 2] = xmlCharStrndup(tmp, size); + if (PyString_Check(value)) { + tmp = PyString_AS_STRING(value); + size = PyString_GET_SIZE(value); + params[(j * 2) + 1] = xmlCharStrndup(tmp, size); + } else { + params[(j * 2) + 1] = NULL; + } + j = j + 1; + } + params[j * 2] = NULL; + params[(j * 2) + 1] = NULL; + } + } else { + printf("libxslt_xsltApplyStylesheet: parameters not a dict\n"); + Py_INCREF(Py_None); + return(Py_None); + } } else { params = NULL; } @@ -266,11 +313,36 @@ libxslt_xsltApplyStylesheet(PyObject *self, PyObject *args) { c_retval = xsltApplyStylesheet(style, doc, params); py_retval = libxml_xmlDocPtrWrap((xmlDocPtr) c_retval); + if (len > 0) { + for (i = 0;i < 2 * len;i++) { + if (params[i] != NULL) + xmlFree((char *)params[i]); + } + xmlFree(params); + } return(py_retval); } /************************************************************************ * * + * Integrated cleanup * + * * + ************************************************************************/ + +PyObject * +libxslt_xsltCleanup(PyObject *self, PyObject *args) { + + if (libxslt_extModuleFunctions != NULL) { + xmlHashFree(libxslt_extModuleFunctions, deallocateCallback); + } + xsltCleanupGlobals(); + xmlCleanupParser(); + Py_INCREF(Py_None); + return(Py_None); +} + +/************************************************************************ + * * * The registration stuff * * * ************************************************************************/ diff --git a/python/libxsltclass.txt b/python/libxsltclass.txt index b4e73424..d3683ab2 100644 --- a/python/libxsltclass.txt +++ b/python/libxsltclass.txt @@ -19,6 +19,7 @@ registerAllExtras() registerAllFunctions() # functions from module python +cleanup() registerExtModuleFunction() # functions from module transform diff --git a/python/tests/basic.py b/python/tests/basic.py index 40a649e6..1c62cde4 100755 --- a/python/tests/basic.py +++ b/python/tests/basic.py @@ -16,8 +16,7 @@ doc.freeDoc() result.freeDoc() # Memory debug specific -libxslt.cleanupGlobals() -libxml2.cleanupParser() +libxslt.cleanup() if libxml2.debugMemory(1) == 0: print "OK" else: diff --git a/python/tests/extfunc.py b/python/tests/extfunc.py index 40f503eb..7e8b2845 100755 --- a/python/tests/extfunc.py +++ b/python/tests/extfunc.py @@ -18,14 +18,15 @@ styledoc = libxml2.parseDoc(""" xmlns:foo='http://example.com/foo' xsl:exclude-result-prefixes='foo'> + <xsl:param name='bar'>failure</xsl:param> <xsl:template match='/'> - <article><xsl:value-of select='foo:foo(\"foo\")'/></article> + <article><xsl:value-of select='foo:foo($bar)'/></article> </xsl:template> </xsl:stylesheet> """) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseDoc("<doc/>") -result = style.applyStylesheet(doc, None) +result = style.applyStylesheet(doc, { "bar": "'success'" }) style = None doc.freeDoc() @@ -33,15 +34,14 @@ root = result.children if root.name != "article": print "Unexpected root node name" sys.exit(1) -if root.content != "FOO": +if root.content != "SUCCESS": print "Unexpected root node content, extension function failed" sys.exit(1) result.freeDoc() # Memory debug specific -libxslt.cleanupGlobals() -libxml2.cleanupParser() +libxslt.cleanup() if libxml2.debugMemory(1) == 0: print "OK" else: |