diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | libxslt/pattern.c | 8 | ||||
-rw-r--r-- | libxslt/transform.c | 31 | ||||
-rw-r--r-- | libxslt/variables.c | 10 | ||||
-rw-r--r-- | tests/docs/Makefile.am | 1 | ||||
-rw-r--r-- | tests/docs/bug-111.xml | 17 | ||||
-rw-r--r-- | tests/exslt/common/node-set.2.out | 2 | ||||
-rw-r--r-- | tests/general/Makefile.am | 1 | ||||
-rw-r--r-- | tests/general/bug-111.out | 6 | ||||
-rw-r--r-- | tests/general/bug-111.xsl | 45 |
10 files changed, 116 insertions, 16 deletions
@@ -1,3 +1,14 @@ +Mon Mar 24 15:01:07 CET 2003 Daniel Veillard <daniel@veillard.com> + + * libxslt/pattern.c libxslt/transform.c libxslt/variables.c: + Finally fixed bug #75813, processing or Result Value Tree + converted into node-sets should be a bit more sensible now. + * tests/exslt/common/node-set.2.out: the associated fix in libxml2 + fixes this regression test, there is 4 nodes, not 3 + * tests/docs/Makefile.am tests/docs/bug-111.* + tests/general/Makefile.am tests/general/bug-111*: added an + example in the regression tests for bug #75813 + Sun Mar 23 13:09:17 CET 2003 Daniel Veillard <daniel@veillard.com> * tests/docs/Makefile.am tests/docs/bug-110.* diff --git a/libxslt/pattern.c b/libxslt/pattern.c index dc2ed01f..53ae86c0 100644 --- a/libxslt/pattern.c +++ b/libxslt/pattern.c @@ -611,6 +611,8 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, xmlChar *query; xmlXPathObjectPtr newlist; xmlNodePtr parent = node->parent; + xmlDocPtr olddoc; + xmlNodePtr oldnode; if (comp->pattern[0] == '/') query = xmlStrdup(comp->pattern); @@ -618,7 +620,13 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp, query = xmlStrdup((const xmlChar *)"//"); query = xmlStrcat(query, comp->pattern); } + oldnode = ctxt->xpathCtxt->node; + olddoc = ctxt->xpathCtxt->doc; + ctxt->xpathCtxt->node = node; + ctxt->xpathCtxt->doc = doc; newlist = xmlXPathEval(query, ctxt->xpathCtxt); + ctxt->xpathCtxt->node = oldnode; + ctxt->xpathCtxt->doc = olddoc; xmlFree(query); if (newlist == NULL) return(-1); diff --git a/libxslt/transform.c b/libxslt/transform.c index 9c6e40d6..6901657d 100644 --- a/libxslt/transform.c +++ b/libxslt/transform.c @@ -3064,18 +3064,27 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, (list->nodeTab[i]->doc->doc)!=ctxt->xpathCtxt->doc) { /* The nodeset is from another document, so must change */ ctxt->xpathCtxt->doc=list->nodeTab[i]->doc->doc; - if ((ctxt->document = - xsltFindDocument(ctxt,list->nodeTab[i]->doc->doc))==NULL) { - xsltTransformError(ctxt, NULL, inst, - "xsl:apply-templates : can't find doc\n"); - goto error; - } - ctxt->xpathCtxt->node = list->nodeTab[i]; + if (list->nodeTab[i]->doc->type != XML_ELEMENT_NODE) { + if ((ctxt->document = xsltFindDocument(ctxt, + list->nodeTab[i]->doc->doc))==NULL) { + xsltTransformError(ctxt, NULL, inst, + "xsl:apply-templates : can't find doc\n"); + goto error; + } + ctxt->xpathCtxt->node = list->nodeTab[i]; #ifdef WITH_XSLT_DEBUG_PROCESS - xsltGenericDebug(xsltGenericDebugContext, - "xsltApplyTemplates: Changing document - context doc %s, xpathdoc %s\n", - ctxt->document->doc->URL, ctxt->xpathCtxt->doc->URL); + xsltGenericDebug(xsltGenericDebugContext, + "xsltApplyTemplates: Changing document - context doc %s, xpathdoc %s\n", + ctxt->document->doc->URL, ctxt->xpathCtxt->doc->URL); #endif + } else { + ctxt->xpathCtxt->node = list->nodeTab[i]; + ctxt->document = NULL; +#ifdef WITH_XSLT_DEBUG_PROCESS + xsltGenericDebug(xsltGenericDebugContext, + "xsltApplyTemplates: Changing document - Return tree fragment\n"); +#endif + } } xsltProcessOneNode(ctxt, list->nodeTab[i], params); } @@ -3833,7 +3842,7 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc, if ((res != NULL) && (ctxt != NULL) && (output != NULL)) { int ret; - ret = xsltCheckWrite(userCtxt->sec, userCtxt, output); + ret = xsltCheckWrite(userCtxt->sec, userCtxt, (const xmlChar *) output); if (ret == 0) { xsltTransformError(ctxt, NULL, NULL, "xsltApplyStylesheet: forbidden to save to %s\n", diff --git a/libxslt/variables.c b/libxslt/variables.c index 9f48303b..98b872e9 100644 --- a/libxslt/variables.c +++ b/libxslt/variables.c @@ -364,14 +364,15 @@ xsltEvalVariable(xsltTransformContextPtr ctxt, xsltStackElemPtr elem, xmlNodePtr oldInsert; xmlDocPtr oldoutput; - container = xmlNewDocNode(ctxt->document->doc, NULL, + container = xmlNewDocNode(NULL, NULL, (const xmlChar *) " fake node libxslt", NULL); if (container == NULL) return(NULL); + container->doc = (xmlDocPtr) container; container->parent = NULL; oldoutput = ctxt->output; - ctxt->output = NULL; + ctxt->output = (xmlDocPtr) container; oldInsert = ctxt->insert; ctxt->insert = container; xsltApplyOneTemplate(ctxt, ctxt->node, elem->tree, NULL, NULL); @@ -500,16 +501,17 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) { xmlNodePtr oldInsert; xmlDocPtr oldoutput; - container = xmlNewDocNode(ctxt->document->doc, NULL, + container = xmlNewDocNode(NULL , NULL, (const xmlChar *) " fake node libxslt", NULL); if (container == NULL) { elem->name = name; return(NULL); } + container->doc = (xmlDocPtr) container; container->parent = NULL; oldoutput = ctxt->output; - ctxt->output = NULL; + ctxt->output = (xmlDocPtr) container; oldInsert = ctxt->insert; ctxt->insert = container; xsltApplyOneTemplate(ctxt, ctxt->node, elem->tree, NULL, NULL); diff --git a/tests/docs/Makefile.am b/tests/docs/Makefile.am index 6ce4f6fb..ec7d70ad 100644 --- a/tests/docs/Makefile.am +++ b/tests/docs/Makefile.am @@ -110,6 +110,7 @@ EXTRA_DIST = \ bug-108.xml \ bug-109.xml \ bug-110.xml bug-110.ent \ + bug-111.xml \ character.xml \ array.xml \ items.xml diff --git a/tests/docs/bug-111.xml b/tests/docs/bug-111.xml new file mode 100644 index 00000000..b10f5152 --- /dev/null +++ b/tests/docs/bug-111.xml @@ -0,0 +1,17 @@ +<?xml version="1.0"?>
+ <DIRTREE dirpath="c:\file" dirname="file">
+ <f n="AdditionalInfo.bmp" s="1999194" m="03/06/2002 11:21" a=" A" />
+ <f n="AdditionalInfo.jpg" s="65835" m="03/15/2002 13:43" a=" A" />
+ <f n="jdesupport.htm" s="6264" m="03/15/2002 13:32" a=" A" />
+ <f n="LoginScreen.bmp" s="1410914" m="03/06/2002 11:18" a=" A" />
+ <f n="MainScreen.bmp" s="1683330" m="03/06/2002 11:16" a=" A" />
+ <f n="MainScreen.jpg" s="46339" m="03/15/2002 13:43" a=" A" />
+ <f n="newsa.htm" s="3646" m="03/15/2002 13:41" a=" A" />
+ <f n="OutputOptions.bmp" s="1216234" m="03/06/2002 11:22" a=" A" />
+ <f n="ReportSysOverview.bmp" s="2008270" m="03/06/2002 11:23" a=" A" />
+ <f n="ReportViewer.jpg" s="56653" m="03/15/2002 13:44" a=" A" />
+ <f n="SelectProfile.bmp" s="1683330" m="03/06/2002 11:17" a=" A" />
+ <f n="SelectProfile.jpg" s="71648" m="03/15/2002 11:06" a=" A" />
+ <d name="utils" />
+ </DIRTREE>
+
diff --git a/tests/exslt/common/node-set.2.out b/tests/exslt/common/node-set.2.out index bae9ab2d..8b50a796 100644 --- a/tests/exslt/common/node-set.2.out +++ b/tests/exslt/common/node-set.2.out @@ -1,2 +1,2 @@ <?xml version="1.0"?> -<out xmlns:exslt="http://exslt.org/common">3</out> +<out xmlns:exslt="http://exslt.org/common">4</out> diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am index bf4601b7..a2665c54 100644 --- a/tests/general/Makefile.am +++ b/tests/general/Makefile.am @@ -115,6 +115,7 @@ EXTRA_DIST = \ bug-108.out bug-108.xsl \ bug-109.out bug-109.xsl \ bug-110.out bug-110.xsl \ + bug-111.out bug-111.xsl \ character.out character.xsl \ character2.out character2.xsl \ itemschoose.out itemschoose.xsl \ diff --git a/tests/general/bug-111.out b/tests/general/bug-111.out new file mode 100644 index 00000000..012d3b50 --- /dev/null +++ b/tests/general/bug-111.out @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<root> + Test 1 + DIRTREE : true : true + Test 2 + DIRTREE : true : true</root> diff --git a/tests/general/bug-111.xsl b/tests/general/bug-111.xsl new file mode 100644 index 00000000..20d66844 --- /dev/null +++ b/tests/general/bug-111.xsl @@ -0,0 +1,45 @@ +<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:exsl="http://exslt.org/common"
+ extension-element-prefixes="exsl"
+ exclude-result-prefixes="exsl">
+
+
+<xsl:template match="/">
+<root>
+ <xsl:variable name="dtree">
+ <DIRTREE dirpath="c:\file" dirname="file">
+ <f n="AdditionalInfo.bmp" s="1999194" m="03/06/2002 11:21" a=" A" />
+ <f n="AdditionalInfo.jpg" s="65835" m="03/15/2002 13:43" a=" A" />
+ <f n="jdesupport.htm" s="6264" m="03/15/2002 13:32" a=" A" />
+ <f n="LoginScreen.bmp" s="1410914" m="03/06/2002 11:18" a=" A" />
+ <f n="MainScreen.bmp" s="1683330" m="03/06/2002 11:16" a=" A" />
+ <f n="MainScreen.jpg" s="46339" m="03/15/2002 13:43" a=" A" />
+ <f n="newsa.htm" s="3646" m="03/15/2002 13:41" a=" A" />
+ <f n="OutputOptions.bmp" s="1216234" m="03/06/2002 11:22" a=" A" />
+ <f n="ReportSysOverview.bmp" s="2008270" m="03/06/2002 11:23" a=" A" />
+ <f n="ReportViewer.jpg" s="56653" m="03/15/2002 13:44" a=" A" />
+ <f n="SelectProfile.bmp" s="1683330" m="03/06/2002 11:17" a=" A" />
+ <f n="SelectProfile.jpg" s="71648" m="03/15/2002 11:06" a=" A" />
+ <d name="utils" />
+ </DIRTREE>
+ </xsl:variable>
+ Test 1
+ <xsl:apply-templates select="exsl:node-set($dtree)/DIRTREE"/>
+ Test 2
+ <xsl:apply-templates select="/DIRTREE"/>
+
+</root>
+</xsl:template>
+
+<xsl:template match="DIRTREE[d][f]" priority="100">
+ <xsl:value-of select="name()"/> : <xsl:value-of select="boolean(d)"/> : <xsl:value-of select="boolean(f)"/>
+
+</xsl:template>
+
+<xsl:template match="@*|node()">
+ Default Template Match Found
+</xsl:template>
+
+</xsl:stylesheet>
+
|