Re: [xslt] XSL Sort + ICU



Hi,

> Attached is the diff file for the pluggable sort function.
> I've modified the libxslt.def.src file to add the two new public functions,
> but I'm not sure what else will need changing to know about them - I've
> never got round to figuring how the build procedures work on either linux or
> windows...

I am attaching the new diff with corrected exports on Windows. 
xmlDoSortFunction must be exported as well, This time as a variable.

Ciao
Igor
Index: libxslt/libxslt/preproc.c
===================================================================
RCS file: /cvs/gnome/libxslt/libxslt/preproc.c,v
retrieving revision 1.37
diff -c -r1.37 preproc.c
*** libxslt/libxslt/preproc.c	22 Oct 2002 15:33:12 -0000	1.37
--- libxslt/libxslt/preproc.c	27 Nov 2002 10:56:04 -0000
***************
*** 332,339 ****
  	    style->warnings++;
  	}
      }
!     /* TODO: xsl:sort lang attribute */
!     /* TODO: xsl:sort case-order attribute */
  
      comp->select = xsltGetNsProp(inst,(const xmlChar *)"select", XSLT_NAMESPACE);
      if (comp->select == NULL) {
--- 332,356 ----
  	    style->warnings++;
  	}
      }
!     comp->case_order = xsltEvalStaticAttrValueTemplate(style, inst,
! 			      (const xmlChar *)"case-order",
! 			      XSLT_NAMESPACE, &comp->has_order);
!     if (comp->case_order != NULL) {
! 	if (xmlStrEqual(comp->case_order, (const xmlChar *) "upper-first"))
! 	    comp->lower_first = 0;
! 	else if (xmlStrEqual(comp->case_order, (const xmlChar *) "lower-first"))
! 	    comp->lower_first = 1;
! 	else {
! 	    xsltTransformError(NULL, style, inst,
! 		 "xsltSortComp: invalid value %s for order\n", comp->order);
! 	    comp->lower_first = 0; /* use default */
! 	    style->warnings++;
! 	}
!     }
! 
!     comp->lang = xsltEvalStaticAttrValueTemplate(style, inst,
! 				 (const xmlChar *)"lang",
! 				 XSLT_NAMESPACE, &comp->has_lang);
  
      comp->select = xsltGetNsProp(inst,(const xmlChar *)"select", XSLT_NAMESPACE);
      if (comp->select == NULL) {
Index: libxslt/libxslt/xsltInternals.h
===================================================================
RCS file: /cvs/gnome/libxslt/libxslt/xsltInternals.h,v
retrieving revision 1.70
diff -c -r1.70 xsltInternals.h
*** libxslt/libxslt/xsltInternals.h	23 Nov 2002 11:36:05 -0000	1.70
--- libxslt/libxslt/xsltInternals.h	27 Nov 2002 10:56:04 -0000
***************
*** 223,228 ****
--- 223,232 ----
      xmlChar *order;             /* sort */
      int      has_order;		/* sort */
      int      descending;	/* sort */
+     xmlChar *lang;		/* sort */
+     int      has_lang;		/* sort */
+     xmlChar *case_order;	/* sort */
+     int      lower_first;	/* sort */
  
      xmlChar *use;		/* copy, element */
      int      has_use;		/* copy, element */
Index: libxslt/libxslt/xsltutils.c
===================================================================
RCS file: /cvs/gnome/libxslt/libxslt/xsltutils.c,v
retrieving revision 1.66
diff -c -r1.66 xsltutils.c
*** libxslt/libxslt/xsltutils.c	4 Nov 2002 17:04:59 -0000	1.66
--- libxslt/libxslt/xsltutils.c	27 Nov 2002 10:56:04 -0000
***************
*** 636,642 ****
   * reorder the current node list accordingly to the set of sorting
   * requirement provided by the array of nodes.
   */
! static xmlXPathObjectPtr *
  xsltComputeSortResult(xsltTransformContextPtr ctxt, xmlNodePtr sort) {
      xmlXPathObjectPtr *results = NULL;
      xmlNodeSetPtr list = NULL;
--- 636,642 ----
   * reorder the current node list accordingly to the set of sorting
   * requirement provided by the array of nodes.
   */
! xmlXPathObjectPtr *
  xsltComputeSortResult(xsltTransformContextPtr ctxt, xmlNodePtr sort) {
      xmlXPathObjectPtr *results = NULL;
      xmlNodeSetPtr list = NULL;
***************
*** 735,741 ****
  }
  
  /**
!  * xsltDoSortFunction:
   * @ctxt:  a XSLT process context
   * @sorts:  array of sort nodes
   * @nbsorts:  the number of sorts in the array
--- 735,741 ----
  }
  
  /**
!  * xsltDefaultSortFunction:
   * @ctxt:  a XSLT process context
   * @sorts:  array of sort nodes
   * @nbsorts:  the number of sorts in the array
***************
*** 744,750 ****
   * requirement provided by the arry of nodes.
   */
  void	
! xsltDoSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
  	           int nbsorts) {
      xmlXPathObjectPtr *resultsTab[XSLT_MAX_SORT];
      xmlXPathObjectPtr *results = NULL, *res;
--- 744,750 ----
   * requirement provided by the arry of nodes.
   */
  void	
! xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
  	           int nbsorts) {
      xmlXPathObjectPtr *resultsTab[XSLT_MAX_SORT];
      xmlXPathObjectPtr *results = NULL, *res;
***************
*** 955,960 ****
--- 955,976 ----
      }
  }
  
+ xsltSortFunc xsltDoSortFunction = xsltDefaultSortFunction;
+ 
+ /**
+  * xsltSetSortFunc:
+  * @handler:  the new handler function
+  *
+  * Function to reset the handler for XSLT sorting.
+  */
+ void
+ xsltSetSortFunc(xsltSortFunc handler) {
+     if (handler != NULL)
+ 	xsltDoSortFunction = handler;
+     else
+ 	xsltDoSortFunction = xsltDefaultSortFunction;
+ }
+ 
  /************************************************************************
   * 									*
   * 				Output					*
***************
*** 1613,1616 ****
--- 1629,1633 ----
      if (xsltDebuggerCurrentCallbacks.drop != NULL)
  	xsltDebuggerCurrentCallbacks.drop();
  }
+ 
  
Index: libxslt/libxslt/xsltutils.h
===================================================================
RCS file: /cvs/gnome/libxslt/libxslt/xsltutils.h,v
retrieving revision 1.31
diff -c -r1.31 xsltutils.h
*** libxslt/libxslt/xsltutils.h	22 Oct 2002 15:33:12 -0000	1.31
--- libxslt/libxslt/xsltutils.h	27 Nov 2002 10:56:05 -0000
***************
*** 84,89 ****
--- 84,100 ----
        ((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.
   */
***************
*** 125,133 ****
   */
  
  void		xsltDocumentSortFunction	(xmlNodeSetPtr list);
! void		xsltDoSortFunction		(xsltTransformContextPtr ctxt,
! 						 xmlNodePtr *sorts,
! 						 int nbsorts);
  
  /*
   * QNames handling.
--- 136,144 ----
   */
  
  void		xsltDocumentSortFunction	(xmlNodeSetPtr list);
! LIBXSLT_PUBLIC extern xsltSortFunc xsltDoSortFunction;
! void		xsltSetSortFunc			(xsltSortFunc handler);
! xmlXPathObjectPtr *xsltComputeSortResult(xsltTransformContextPtr ctxt, xmlNodePtr sort);
  
  /*
   * QNames handling.
***************
*** 202,205 ****
--- 213,217 ----
  #endif
  
  #endif /* __XML_XSLTUTILS_H__ */
+ 
  
Index: libxslt/win32/libxslt.def.src
===================================================================
RCS file: /cvs/gnome/libxslt/win32/libxslt.def.src,v
retrieving revision 1.5
diff -c -r1.5 libxslt.def.src
*** libxslt/win32/libxslt.def.src	23 Nov 2002 21:47:56 -0000	1.5
--- libxslt/win32/libxslt.def.src	27 Nov 2002 10:56:06 -0000
***************
*** 313,319 ****
  
  	/* Sorting. */
  	xsltDocumentSortFunction
! 	xsltDoSortFunction
  
  	/* QNames handling. */
  	xsltGetQNameURI
--- 313,321 ----
  
  	/* Sorting. */
  	xsltDocumentSortFunction
! 	xsltDoSortFunction DATA
! 	xsltComputeSortResult
! 	xsltSetSortFunc
  
  	/* QNames handling. */
  	xsltGetQNameURI


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]