+Thu Nov 28 17:52:21 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+ * 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 <daniel@veillard.com>
* libxslt/preproc.c libxslt/xsltInternals.h libxslt/xsltutils.c
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,
xmlGenericErrorFunc error; /* a specific error handler */
void * errctx; /* context for the error handler */
+
+ xsltSortFunc sortfunc; /* a ctxt specific sort routine */
};
/**
*
* 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);
}
* 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) {
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 *
((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.
*/
void xsltDocumentSortFunction (xmlNodeSetPtr list);
void xsltSetSortFunc (xsltSortFunc handler);
+void xsltSetCtxtSortFunc (xsltTransformContextPtr ctxt,
+ xsltSortFunc handler);
void xsltDefaultSortFunction (xsltTransformContextPtr ctxt,
xmlNodePtr *sorts,
int nbsorts);