[libxslt] Set correct context node when initializing xsl:keys



commit ce5a0dd6a70efdb214aba12fefc6bbf8c201b838
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Fri Dec 13 13:40:32 2013 +0100

    Set correct context node when initializing xsl:keys
    
    This makes the current() function in "use" expressions work properly.
    Fixes bugs #530871, #607893, and #676335.

 libxslt/keys.c            |    1 +
 tests/docs/bug-183.xml    |    5 +++++
 tests/general/bug-183.out |    2 ++
 tests/general/bug-183.xsl |    9 +++++++++
 4 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/libxslt/keys.c b/libxslt/keys.c
index b8f1455..43a343e 100644
--- a/libxslt/keys.c
+++ b/libxslt/keys.c
@@ -759,6 +759,7 @@ fprintf(stderr, "xsltInitCtxtKey %s : %d\n", keyDef->name, ctxt->keyInitLevel);
        cur = matchList->nodeTab[i];
        if (! IS_XSLT_REAL_NODE(cur))
            continue;
+        ctxt->node = cur;
        xpctxt->node = cur;
        /*
        * Process the 'use' of the xsl:key.
diff --git a/tests/docs/bug-183.xml b/tests/docs/bug-183.xml
new file mode 100644
index 0000000..bcd45a8
--- /dev/null
+++ b/tests/docs/bug-183.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<root>
+    <val k="one">hello</val>
+    <val k="two">2</val>
+</root>
diff --git a/tests/general/bug-183.out b/tests/general/bug-183.out
new file mode 100644
index 0000000..e38fb43
--- /dev/null
+++ b/tests/general/bug-183.out
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<result>hello</result>
diff --git a/tests/general/bug-183.xsl b/tests/general/bug-183.xsl
new file mode 100644
index 0000000..429951f
--- /dev/null
+++ b/tests/general/bug-183.xsl
@@ -0,0 +1,9 @@
+<?xml version='1.0'?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
+<xsl:key name="index" match="val" use="current()/@k"/>
+<xsl:template match="/">
+    <result>
+        <xsl:value-of select="key('index', 'one')"/>
+    </result>
+</xsl:template>
+</xsl:stylesheet>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]