diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2010-11-08 10:59:24 +0100 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2010-11-08 10:59:24 +0100 |
commit | 1d46bcde37e5985a7568a5d1e3ce0f01e4d41001 (patch) | |
tree | bafff8ba54b45127f63135011cd0eec372379734 | |
parent | 8dbe0f082a2e41b4885d373e1ab5df03605e2321 (diff) | |
download | libxslt-1d46bcde37e5985a7568a5d1e3ce0f01e4d41001.tar.gz |
Fix bug 602515
Pattern matching with predicates
-rw-r--r-- | libxslt/pattern.c | 17 | ||||
-rw-r--r-- | tests/docs/bug-171.xml | 4 | ||||
-rw-r--r-- | tests/general/Makefile.am | 1 | ||||
-rw-r--r-- | tests/general/bug-171.out | 2 | ||||
-rw-r--r-- | tests/general/bug-171.xsl | 7 |
5 files changed, 22 insertions, 9 deletions
diff --git a/libxslt/pattern.c b/libxslt/pattern.c index 58bd6edb..6161376e 100644 --- a/libxslt/pattern.c +++ b/libxslt/pattern.c @@ -888,11 +888,10 @@ restart: (node->type == XML_ELEMENT_NODE) && (node->parent != NULL)) { xmlNodePtr previous; - int ix, nocache = 0; + int nocache = 0; previous = (xmlNodePtr) XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr); - ix = XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival); if ((previous != NULL) && (previous->parent == node->parent)) { /* @@ -904,7 +903,7 @@ restart: while (sibling != NULL) { if (sibling == previous) break; - if ((previous->type == XML_ELEMENT_NODE) && + if ((sibling->type == XML_ELEMENT_NODE) && (previous->name != NULL) && (sibling->name != NULL) && (previous->name[0] == sibling->name[0]) && @@ -925,7 +924,7 @@ restart: while (sibling != NULL) { if (sibling == previous) break; - if ((previous->type == XML_ELEMENT_NODE) && + if ((sibling->type == XML_ELEMENT_NODE) && (previous->name != NULL) && (sibling->name != NULL) && (previous->name[0] == sibling->name[0]) && @@ -943,7 +942,8 @@ restart: } } if (sibling != NULL) { - pos = ix + indx; + pos = XSLT_RUNTIME_EXTRA(ctxt, + sel->indexExtra, ival) + indx; /* * If the node is in a Value Tree we need to * save len, but cannot cache the node! @@ -959,7 +959,6 @@ restart: sel->indexExtra, ival) = pos; } } - ix = pos; } else pos = 0; } else { @@ -1020,11 +1019,10 @@ restart: } else if ((sel != NULL) && (sel->op == XSLT_OP_ALL) && (node->type == XML_ELEMENT_NODE)) { xmlNodePtr previous; - int ix, nocache = 0; + int nocache = 0; previous = (xmlNodePtr) XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr); - ix = XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival); if ((previous != NULL) && (previous->parent == node->parent)) { /* @@ -1053,7 +1051,8 @@ restart: } } if (sibling != NULL) { - pos = ix + indx; + pos = XSLT_RUNTIME_EXTRA(ctxt, + sel->indexExtra, ival) + indx; /* * If the node is in a Value Tree we cannot * cache it ! diff --git a/tests/docs/bug-171.xml b/tests/docs/bug-171.xml new file mode 100644 index 00000000..658021be --- /dev/null +++ b/tests/docs/bug-171.xml @@ -0,0 +1,4 @@ +<root> + <text>one</text> + <text>two</text> +</root> diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am index e33a6c63..7207e15f 100644 --- a/tests/general/Makefile.am +++ b/tests/general/Makefile.am @@ -178,6 +178,7 @@ EXTRA_DIST = \ bug-168.out bug-168.xsl \ bug-169.out bug-169.xsl bug-169.imp \ bug-170.out bug-170.xsl \ + bug-171.out bug-171.xsl \ character.out character.xsl \ character2.out character2.xsl \ itemschoose.out itemschoose.xsl \ diff --git a/tests/general/bug-171.out b/tests/general/bug-171.out new file mode 100644 index 00000000..5b87d4f5 --- /dev/null +++ b/tests/general/bug-171.out @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +two diff --git a/tests/general/bug-171.xsl b/tests/general/bug-171.xsl new file mode 100644 index 00000000..25a7c94d --- /dev/null +++ b/tests/general/bug-171.xsl @@ -0,0 +1,7 @@ +<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:template match="text[2]"> + <xsl:value-of select="."/> + </xsl:template> + + <xsl:template match="text()"/> +</xsl:transform> |