[xslt] Problem with key()



Hi,

(Daniel: this is a better description of the bug I mentioned to you in
an email earlier today.)

I'm having trouble getting the key() function to work when the second
argument is a nodeset, rather than a string.

xsltproc segfaults on the following xsl fragment:

<xsl:key name="idkey" match="div" use="@id"/>

<xsl:template match="doc">
  <xsl:value-of select="key('idkey',@target)"/>
</xsl:template>

run on the following xml file:

<doc target="lookup">
  <div id="lookup">Success</div>
  <div id="unwanted">Failed</div>
</doc>


(this is a modified version of REC/test-12.2-1)

I tried to trace the execution under gdb, but I get caught in a
seemingly infinite recursion in xsltKeyFunction():

   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]));
		xsltKeyFunction(ctxt, 2);
		newobj = valuePop(ctxt);
		ret->nodesetval = xmlXPathNodeSetMerge(ret->nodesetval,
						       newobj->nodesetval);
		xmlXPathFreeObject(newobj);
	    }
	}
	valuePush(ctxt, ret);
    }


I'm afraid this is where my knowledge stops.  I'm not familiar enough
with the libxslt source to be able to say what's supposed to happen
here.

--Brent

-------------------------------------------------------------------------

"The programmer, like the poet, works only slightly removed from pure
 thought-stuff.  He builds his castles in the air, from air, creating
 by exertion of the imagination.  Few media of creation are so
 flexible, so easy to polish and rework, so readily capable of
 realizing grand conceptual structures."
                        -- Frederick Brooks, Jr., The Mythical Man Month




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