From bb0915168b7a572a203f55c13edd14c5ffdb0233 Mon Sep 17 00:00:00 2001 From: "William M. Brack" Date: Sun, 22 Aug 2004 05:24:46 +0000 Subject: [PATCH] Further enhancement for keys on exslt:node-sets. Corrects a rather serious * transform.c: Further enhancement for keys on exslt:node-sets. Corrects a rather serious timing problem (bug 150741) * tests/exslt/common/node-set.8.*: added regression test for this --- ChangeLog | 6 ++++++ libxslt/transform.c | 39 ++++++++++++--------------------------- tests/exslt/common/Makefile.am | 1 + tests/exslt/common/node-set.8.out | 2 ++ tests/exslt/common/node-set.8.xml | 2 ++ tests/exslt/common/node-set.8.xsl | 30 ++++++++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 27 deletions(-) create mode 100644 tests/exslt/common/node-set.8.out create mode 100644 tests/exslt/common/node-set.8.xml create mode 100644 tests/exslt/common/node-set.8.xsl diff --git a/ChangeLog b/ChangeLog index 8f37fa8..faf3725 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Aug 21 22:08:14 PDT 2004 William Brack + + * transform.c: Further enhancement for keys on exslt:node-sets. + Corrects a rather serious timing problem (bug 150741) + * tests/exslt/common/node-set.8.*: added regression test for this + Fri Aug 20 18:53:50 CEST 2004 Daniel Veillard * Makefile.am configure.in: a bit of cleanup and a extra variable for diff --git a/libxslt/transform.c b/libxslt/transform.c index 3e0cd60..e5cc493 100644 --- a/libxslt/transform.c +++ b/libxslt/transform.c @@ -3127,8 +3127,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, int nbsorts = 0; xmlNodePtr sorts[XSLT_MAX_SORT]; xmlDocPtr oldXDocPtr; - xsltDocumentPtr oldCDocPtr, newDocPtr = NULL; - xmlNodePtr newDocPtrPtr = NULL; + xsltDocumentPtr oldCDocPtr; int oldNsNr; xmlNsPtr *oldNamespaces; @@ -3193,29 +3192,26 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, 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()) + We create a "pseudo-doc" (if not already created) and + store it's pointer into _private. This doc, together + with the keyset, will be freed when the RVT is freed. */ if ((list != NULL) && (ctxt->document->keys != NULL)) { if ((list->nodeNr != 0) && (list->nodeTab[0]->doc != NULL) && (xmlStrEqual((xmlChar *)list->nodeTab[0]->doc->name, (const xmlChar *) " fake node libxslt")) && - (list->nodeTab[0]->doc->psvi == NULL)) { - newDocPtr = xsltNewDocument(ctxt, - list->nodeTab[0]->doc); - if (newDocPtr == NULL) { + (list->nodeTab[0]->doc->_private == NULL)) { + list->nodeTab[0]->doc->_private = xsltNewDocument( + ctxt, list->nodeTab[0]->doc); + if (list->nodeTab[0]->doc->_private == NULL) { xsltTransformError(ctxt, NULL, inst, "xsltApplyTemplates : failed to allocate subdoc\n"); } - if (list->nodeTab[0]->type == XML_ELEMENT_NODE) { - list->nodeTab[0]->psvi = (xmlNodePtr)newDocPtr; - } else - if ((list->nodeTab[0]->type == XML_ELEMENT_NODE) || - (list->nodeTab[0]->type == XML_DOCUMENT_NODE)) { - list->nodeTab[0]->psvi = (xmlNodePtr)newDocPtr; - newDocPtrPtr = list->nodeTab[0]; - } - ctxt->document = newDocPtr; + + ctxt->document = list->nodeTab[0]->doc->_private; } + } } else { list = NULL; @@ -3390,19 +3386,8 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, error: if (params != NULL) xsltFreeStackElemList(params); /* free the parameter list */ - if (list != NULL) { - /* - If we created a "pseudo-document" we must free it now - */ - if (newDocPtr != NULL) { - newDocPtr->doc->parent = NULL; - xsltFreeDocumentKeys(newDocPtr); - xmlFree(newDocPtr); - if (newDocPtrPtr != NULL) - newDocPtrPtr->psvi = NULL; - } + if (list != NULL) xmlXPathFreeNodeSet(list); - } /* * res must be deallocated after list */ diff --git a/tests/exslt/common/Makefile.am b/tests/exslt/common/Makefile.am index 39decd9..176ec77 100644 --- a/tests/exslt/common/Makefile.am +++ b/tests/exslt/common/Makefile.am @@ -11,6 +11,7 @@ EXTRA_DIST = \ node-set.5.xml node-set.5.xsl node-set.5.out \ node-set.6.xml node-set.6.xsl node-set.6.out \ node-set.7.xml node-set.7.xsl node-set.7.out \ + node-set.8.xml node-set.8.xsl node-set.8.out \ object-type.1.xml object-type.1.xsl object-type.1.out \ import-test1a.imp import-test1b.imp import-test1.out \ import-test1.xml import-test1.xsl diff --git a/tests/exslt/common/node-set.8.out b/tests/exslt/common/node-set.8.out new file mode 100644 index 0000000..6190fa9 --- /dev/null +++ b/tests/exslt/common/node-set.8.out @@ -0,0 +1,2 @@ + + diff --git a/tests/exslt/common/node-set.8.xml b/tests/exslt/common/node-set.8.xml new file mode 100644 index 0000000..6190fa9 --- /dev/null +++ b/tests/exslt/common/node-set.8.xml @@ -0,0 +1,2 @@ + + diff --git a/tests/exslt/common/node-set.8.xsl b/tests/exslt/common/node-set.8.xsl new file mode 100644 index 0000000..b855529 --- /dev/null +++ b/tests/exslt/common/node-set.8.xsl @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.7.4