From a8fbad39afd072f40de317fd7f5972b74a43fbc0 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 28 Nov 2002 16:55:56 +0000 Subject: [PATCH] applied another patch from Richard Jinks for the export of teh sorting * libxslt/xsltInternals.h libxslt/xsltutils.c libxslt/xsltutils.h win32/libxslt.def.src: applied another patch from Richard Jinks for the export of teh sorting routine and allowing per context sort. Daniel --- ChangeLog | 7 +++++++ libxslt/xsltInternals.h | 13 +++++++++++++ libxslt/xsltutils.c | 29 +++++++++++++++++++++++++---- libxslt/xsltutils.h | 13 ++----------- win32/libxslt.def.src | 2 ++ 5 files changed, 49 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index f0aac3b9..8ad764d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Nov 28 17:52:21 CET 2002 Daniel Veillard + + * libxslt/xsltInternals.h libxslt/xsltutils.c libxslt/xsltutils.h + win32/libxslt.def.src: applied another patch from Richard Jinks + for the export of teh sorting routine and allowing per context + sort. + Wed Nov 27 13:33:26 CET 2002 Daniel Veillard * libxslt/preproc.c libxslt/xsltInternals.h libxslt/xsltutils.c diff --git a/libxslt/xsltInternals.h b/libxslt/xsltInternals.h index cbe9e158..fd3f4670 100644 --- a/libxslt/xsltInternals.h +++ b/libxslt/xsltInternals.h @@ -148,6 +148,17 @@ typedef void (*xsltTransformFunction) (xsltTransformContextPtr ctxt, xmlNodePtr inst, xsltElemPreCompPtr comp); +/** + * xsltSortFunc: + * @ctxt: a transformation context + * @sorts: the node-set to sort + * @nbsorts: the number of sorts + * + * Signature of the function to use during sorting + */ +typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts, + int nbsorts); + typedef enum { XSLT_FUNC_COPY=1, XSLT_FUNC_SORT, @@ -464,6 +475,8 @@ struct _xsltTransformContext { xmlGenericErrorFunc error; /* a specific error handler */ void * errctx; /* context for the error handler */ + + xsltSortFunc sortfunc; /* a ctxt specific sort routine */ }; /** diff --git a/libxslt/xsltutils.c b/libxslt/xsltutils.c index 22304d12..58922a08 100644 --- a/libxslt/xsltutils.c +++ b/libxslt/xsltutils.c @@ -966,14 +966,19 @@ static xsltSortFunc xsltSortFunction = xsltDefaultSortFunction; * * reorder the current node list accordingly to the set of sorting * requirement provided by the arry of nodes. - * This is a wrapper function, the actual function used can be overriden - * using xsltSetSortFunc() + * This is a wrapper function, the actual function used is specified + * using xsltSetCtxtSortFunc() to set the context specific sort function, + * or xsltSetSortFunc() to set the global sort function. + * If a sort function is set on the context, this will get called. + * Otherwise the global sort function is called. */ void xsltDoSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr * sorts, int nbsorts) { - if (xsltSortFunction != NULL) + if (ctxt->sortfunc != NULL) + (ctxt->sortfunc)(ctxt, sorts, nbsorts); + else if (xsltSortFunction != NULL) xsltSortFunction(ctxt, sorts, nbsorts); } @@ -981,7 +986,8 @@ xsltDoSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr * sorts, * xsltSetSortFunc: * @handler: the new handler function * - * Function to reset the handler for XSLT sorting. + * Function to reset the global handler for XSLT sorting. + * If the handler is NULL, the default sort function will be used. */ void xsltSetSortFunc(xsltSortFunc handler) { @@ -991,6 +997,21 @@ xsltSetSortFunc(xsltSortFunc handler) { xsltSortFunction = xsltDefaultSortFunction; } +/** + * xsltSetCtxtSortFunc: + * @ctxt: a XSLT process context + * @handler: the new handler function + * + * Function to set the handler for XSLT sorting + * for the specified context. + * If the handler is NULL, then the global + * sort function will be called + */ +void +xsltSetCtxtSortFunc(xsltTransformContextPtr ctxt, xsltSortFunc handler) { + ctxt->sortfunc = handler; +} + /************************************************************************ * * * Output * diff --git a/libxslt/xsltutils.h b/libxslt/xsltutils.h index a2041074..b935b419 100644 --- a/libxslt/xsltutils.h +++ b/libxslt/xsltutils.h @@ -84,17 +84,6 @@ extern "C" { ((n)->type == XML_HTML_DOCUMENT_NODE))) #endif -/** - * xsltSortFunc: - * @ctxt: a transformation context - * @sorts: the node-set to sort - * @nbsorts: the number of sorts - * - * Signature of the function to use during sorting - */ -typedef void (*xsltSortFunc) (xsltTransformContextPtr ctxt, xmlNodePtr *sorts, - int nbsorts); - /* * Our own version of namespaced atributes lookup. */ @@ -137,6 +126,8 @@ void xsltTransformError (xsltTransformContextPtr ctxt, void xsltDocumentSortFunction (xmlNodeSetPtr list); void xsltSetSortFunc (xsltSortFunc handler); +void xsltSetCtxtSortFunc (xsltTransformContextPtr ctxt, + xsltSortFunc handler); void xsltDefaultSortFunction (xsltTransformContextPtr ctxt, xmlNodePtr *sorts, int nbsorts); diff --git a/win32/libxslt.def.src b/win32/libxslt.def.src index 805e0b28..ed5e54a9 100644 --- a/win32/libxslt.def.src +++ b/win32/libxslt.def.src @@ -314,7 +314,9 @@ EXPORTS /* Sorting. */ xsltDocumentSortFunction xsltComputeSortResult + xsltDoSortFunction xsltSetSortFunc + xsltSetCtxtSortFunc /* QNames handling. */ xsltGetQNameURI