From 76438ce1bd5412c680a55e43d2847913591054e5 Mon Sep 17 00:00:00 2001 From: "William M. Brack" Date: Sun, 11 Jan 2004 15:34:02 +0000 Subject: [PATCH] Added coding to create a xsltDocument wrapper for an RVT, in order to * libxslt/transform.c: Added coding to create a xsltDocument wrapper for an RVT, in order to produce the applicable keys (Bug 130922) --- ChangeLog | 6 ++++++ libxslt/transform.c | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 72e481a..2ae2bf7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Jan 10 23:33:21 HKT 2004 William Brack + + * libxslt/transform.c: Added coding to create a xsltDocument + wrapper for an RVT, in order to produce the applicable + keys (Bug 130922) + Sat Jan 9 17:04:38 HKT 2004 William Brack * doc/search.xml, doc/search.templ, doc/Makefile.am, diff --git a/libxslt/transform.c b/libxslt/transform.c index 4302897..d81785c 100644 --- a/libxslt/transform.c +++ b/libxslt/transform.c @@ -3048,7 +3048,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, int nbsorts = 0; xmlNodePtr sorts[XSLT_MAX_SORT]; xmlDocPtr oldXDocPtr; - xsltDocumentPtr oldCDocPtr; + xsltDocumentPtr oldCDocPtr, tmpDocPtr, newDocPtr = NULL; int oldNsNr; xmlNsPtr *oldNamespaces; @@ -3109,6 +3109,24 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, if (res->type == XPATH_NODESET) { list = res->nodesetval; res->nodesetval = NULL; + /* + In order to take care of potential keys we need to + do some extra work in the case of an RVT converted + into a nodeset (e.g. exslt:node-set()) + */ + if ((list != NULL) && (ctxt->document->keys != NULL)) { + if ((list->nodeNr != 0) && + (xmlStrEqual((xmlChar *)list->nodeTab[0]->doc->name, + (const xmlChar *) " fake node libxslt")) && + (list->nodeTab[0]->doc->parent == NULL)) { + newDocPtr = xsltNewDocument(ctxt, + list->nodeTab[0]->doc); + if (newDocPtr == NULL) { + } + list->nodeTab[0]->parent = (xmlNodePtr)newDocPtr; + ctxt->document = newDocPtr; + } + } } else { list = NULL; } @@ -3293,8 +3311,21 @@ error: ctxt->node = oldNode; ctxt->mode = oldMode; ctxt->modeURI = oldModeURI; - if (list != NULL) + if (list != NULL) { + /* + If we created a "pseudo-document" we must free it now + */ + if (newDocPtr != NULL) { + tmpDocPtr = (xsltDocumentPtr)&ctxt->docList; + while (tmpDocPtr->next != newDocPtr) + tmpDocPtr = tmpDocPtr->next; + tmpDocPtr->next = newDocPtr->next; + newDocPtr->doc->parent = NULL; + xsltFreeDocumentKeys(newDocPtr); + xmlFree(newDocPtr); + } xmlXPathFreeNodeSet(list); + } /* * res must be deallocated after list */ -- 2.7.4