[tbroyer ltgt net: Re: [xslt] Problem with key()]



Doh, forgot the Cc to xslt gnome org

Since only subscribers are allowed to post to the list (well, you Daniel
may approve a non-subscriber message), wouldn't it be more logical (and
better for all of us) to set the default Reply-To to the list rather than
the sender?

It's also time to make a patch fixing the problem below, and say it isn't
tested at all.

Tom.

Le 18/04/01 00:29:18, Thomas Broyer a écrit :

Le 17/04/01 22:55:31, Brent Hendricks a écrit :
> I'm having trouble getting the key() function to work when the second
> argument is a nodeset, rather than a string.
[...]
> I tried to trace the execution under gdb, but I get caught in a
> seemingly infinite recursion in xsltKeyFunction():

Of course, I forgot converting the node-set to its string value, thus obj2
was always a node-set!

>    if (obj2->type == XPATH_NODESET) {
> 	int i;
> 	xmlXPathObjectPtr newobj, ret;
> 
> 	ret = xmlXPathNewNodeSet(NULL);
> 
> 	if (obj2->nodesetval != NULL) {
> 	    for (i = 0; i < obj2->nodesetval->nodeNr; i++) {
> 		valuePush(ctxt, xmlXPathObjectCopy(obj1));
> 		valuePush(ctxt,
> 			  xmlXPathNewNodeSet(obj2->nodesetval->nodeTab[i]));

Add this:
		xmlXPathStringFunction(ctxt, 1);
here, this should do the trick for now (maybe it'd be better to use
xmlXPathConvertString?)

Tom.
Index: libxslt/functions.c
===================================================================
RCS file: /cvs/gnome/libxslt/libxslt/functions.c,v
retrieving revision 1.18
diff -u -r1.18 functions.c
--- libxslt/functions.c	2001/04/12 12:33:23	1.18
+++ libxslt/functions.c	2001/04/17 23:02:31
@@ -223,6 +223,7 @@
 		valuePush(ctxt, xmlXPathObjectCopy(obj1));
 		valuePush(ctxt,
 			  xmlXPathNewNodeSet(obj2->nodesetval->nodeTab[i]));
+		xmlXPathStringFunction(ctxt, 1);
 		xsltKeyFunction(ctxt, 2);
 		newobj = valuePop(ctxt);
 		ret->nodesetval = xmlXPathNodeSetMerge(ret->nodesetval,


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