Skip to content
Snippets Groups Projects
Commit 57eb51461247 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

make sure the fixup for key() reported by John Escott actually works.

* libxslt/functions.c: make sure the fixup for key() reported
  by John Escott actually works.
* tests/docs/Makefile.am tests/docs/bug-98.xml
  tests/general/Makefile.am tests/general/bug-98.*: added the
  example in the regression tests for this case
Daniel
parent d4d2e9c95064
No related branches found
No related tags found
No related merge requests found
Thu Nov 14 10:03:12 CET 2002 Daniel Veillard <daniel@veillard.com>
* libxslt/functions.c: make sure the fixup for key() reported
by John Escott actually works.
* tests/docs/Makefile.am tests/docs/bug-98.xml
tests/general/Makefile.am tests/general/bug-98.*: added the
example in the regression tests for this case
Wed Nov 13 10:35:46 CET 2002 Daniel Veillard <daniel@veillard.com> Wed Nov 13 10:35:46 CET 2002 Daniel Veillard <daniel@veillard.com>
* libxslt/pattern.c: fixes bug #97969 for @*[...] patterns * libxslt/pattern.c: fixes bug #97969 for @*[...] patterns
......
...@@ -270,4 +270,5 @@ ...@@ -270,4 +270,5 @@
return; return;
} }
obj2 = valuePop(ctxt);
xmlXPathStringFunction(ctxt, 1); xmlXPathStringFunction(ctxt, 1);
...@@ -273,5 +274,4 @@ ...@@ -273,5 +274,4 @@
xmlXPathStringFunction(ctxt, 1); xmlXPathStringFunction(ctxt, 1);
obj2 = valuePop(ctxt);
if ((obj2 == NULL) || if ((obj2 == NULL) ||
(ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) { (ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL, xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
...@@ -283,7 +283,7 @@ ...@@ -283,7 +283,7 @@
} }
obj1 = valuePop(ctxt); obj1 = valuePop(ctxt);
if (obj2->type == XPATH_NODESET) { if ((obj2->type == XPATH_NODESET) || (obj2->type == XPATH_XSLT_TREE)) {
int i; int i;
xmlXPathObjectPtr newobj, ret; xmlXPathObjectPtr newobj, ret;
......
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
bug-95.xml \ bug-95.xml \
bug-96.xml \ bug-96.xml \
bug-97.xml \ bug-97.xml \
bug-98.xml \
character.xml \ character.xml \
array.xml \ array.xml \
items.xml items.xml
......
<?xml version="1.0"?>
<root>
<list type="one"/>
<list type="two"/>
<entries>
<entry cat1="a" cat2="a" qty="1"/>
<entry cat1="a" cat2="b" qty="2"/>
<entry cat1="b" cat2="b" qty="3"/>
</entries>
</root>
...@@ -101,6 +101,7 @@ ...@@ -101,6 +101,7 @@
bug-95.out bug-95.xsl \ bug-95.out bug-95.xsl \
bug-96.out bug-96.xsl \ bug-96.out bug-96.xsl \
bug-97.out bug-97.xsl \ bug-97.out bug-97.xsl \
bug-98.out bug-98.xsl \
character.out character.xsl \ character.out character.xsl \
character2.out character2.xsl \ character2.out character2.xsl \
itemschoose.out itemschoose.xsl \ itemschoose.out itemschoose.xsl \
......
<?xml version="1.0"?>
<result>
<total><type>one</type><a>3</a><b>3</b></total>
<total><type>two</type><a>1</a><b>5</b></total>
</result>
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<result>
<xsl:apply-templates/>
</result>
</xsl:template>
<xsl:key name="k1" match="entry" use="@cat1"/>
<xsl:key name="k2" match="entry" use="@cat2"/>
<xsl:template match="list">
<xsl:variable name="k">
<xsl:choose>
<xsl:when test="@type='one'">k1</xsl:when>
<xsl:otherwise>k2</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<total>
<type>
<xsl:value-of select="@type"/>
</type>
<a>
<xsl:value-of select="sum( key($k,'a')/@qty )"/>
</a>
<b>
<xsl:value-of select="sum( key($k,'b')/@qty )"/>
</b>
</total>
</xsl:template>
<xsl:template match="entries"/>
</xsl:stylesheet>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment