applied another patch from Richard Jinks for the export of teh sorting
authorDaniel Veillard <veillard@src.gnome.org>
Thu, 28 Nov 2002 16:55:56 +0000 (16:55 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Thu, 28 Nov 2002 16:55:56 +0000 (16:55 +0000)
* 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
libxslt/xsltInternals.h
libxslt/xsltutils.c
libxslt/xsltutils.h
win32/libxslt.def.src

index f0aac3b..8ad764d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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
index cbe9e15..fd3f467 100644 (file)
@@ -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 */
 };
 
 /**
index 22304d1..58922a0 100644 (file)
@@ -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                                  *
index a204107..b935b41 100644 (file)
@@ -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);
index 805e0b2..ed5e54a 100644 (file)
@@ -314,7 +314,9 @@ EXPORTS
        /* Sorting. */
        xsltDocumentSortFunction
        xsltComputeSortResult
+       xsltDoSortFunction
        xsltSetSortFunc
+       xsltSetCtxtSortFunc
 
        /* QNames handling. */
        xsltGetQNameURI