Re: [xslt] xsl:number format="{$...}"



On Sat, Jul 14, 2001 at 12:54:26PM +0100, Sebastian Rahtz wrote:
> so you agree that this is a simple oversight in libxslt? it matters
> deeply to me, as I'd have to rewrite my TEI stylesheet family
> considerably to work around it. since nearly all my work does
> numbering, and I parameterize the format, none of my TEI documents can
> work with libxslt :-}

  try the enclosed patch, no guarantee it will solve the problem
in a completely generic fashion but it seems to work on your example.

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
Sep 17-18 2001 Brussels Red Hat TechWorld http://www.redhat-techworld.com
*** numbers.c	2001/07/12 01:32:04	1.20
--- numbers.c	2001/07/14 18:35:47
***************
*** 29,34 ****
--- 29,35 ----
  #include <libxml/xpathInternals.h>
  #include "xsltutils.h"
  #include "pattern.h"
+ #include "templates.h"
  #include "numbersInternals.h"
  
  #ifndef FALSE
***************
*** 599,604 ****
--- 600,614 ----
      int array_amount;
      double number;
      xsltNumberFormatToken array[1024];
+ 
+     if ((data->format == NULL) && (data->has_format != 0)) {
+ 	data->format = xsltEvalAttrValueTemplate(ctxt, data->node,
+ 					     (const xmlChar *) "format",
+ 					     XSLT_NAMESPACE);
+     }
+     if (data->format == NULL) {
+ 	return;
+     }
  
      output = xmlBufferCreate();
      if (output == NULL)
*** numbersInternals.h	2001/06/28 14:23:39	1.7
--- numbersInternals.h	2001/07/14 18:35:47
***************
*** 27,32 ****
--- 27,33 ----
      xmlChar *from;
      xmlChar *value;
      xmlChar *format;
+     int has_format;
      int digitsPerGroup;
      xmlChar groupingCharacter;
      xmlDocPtr doc;
*** preproc.c	2001/07/12 01:32:04	1.25
--- preproc.c	2001/07/14 18:35:47
***************
*** 717,729 ****
      comp->numdata.value = xsltGetNsProp(cur, (const xmlChar *)"value",
  	                                XSLT_NAMESPACE);
      
!     prop = xsltGetNsProp(cur, (const xmlChar *)"format", XSLT_NAMESPACE);
!     if (prop != NULL) {
! 	comp->numdata.format = prop;
!     } else {
  	comp->numdata.format = xmlStrdup(BAD_CAST(""));
      }
!     
      comp->numdata.count = xsltGetNsProp(cur, (const xmlChar *)"count",
  					XSLT_NAMESPACE);
      comp->numdata.from = xsltGetNsProp(cur, (const xmlChar *)"from",
--- 717,731 ----
      comp->numdata.value = xsltGetNsProp(cur, (const xmlChar *)"value",
  	                                XSLT_NAMESPACE);
      
!     prop = xsltEvalStaticAttrValueTemplate(style, cur,
! 			 (const xmlChar *)"format",
! 			 XSLT_NAMESPACE, &comp->numdata.has_format);
!     if (comp->numdata.has_format == 0) {
  	comp->numdata.format = xmlStrdup(BAD_CAST(""));
+     } else {
+ 	comp->numdata.format = prop;
      }
! 
      comp->numdata.count = xsltGetNsProp(cur, (const xmlChar *)"count",
  					XSLT_NAMESPACE);
      comp->numdata.from = xsltGetNsProp(cur, (const xmlChar *)"from",


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