[libxslt] Consider built-in templates in apply-imports



commit 45ea7fc4554ee2f39f0a301346f7bd24108c8228
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Thu May 26 11:38:28 2016 +0200

    Consider built-in templates in apply-imports
    
    The XSLT specification says about the built-in templates: "The built-in
    template rules are treated as if they were imported implicitly before
    the stylesheet and so have lower import precedence than all other
    template rules."
    
    That means that the apply-imports instruction needs to consider
    built-in templates, as "xsl:apply-imports processes the current node
    using only template rules that were imported into the stylesheet
    element".
    
    Fixes bug #654150:
    
    https://bugzilla.gnome.org/show_bug.cgi?id=654150

 libxslt/transform.c       |    4 ++++
 tests/docs/bug-193.xml    |    1 +
 tests/general/bug-193.out |    2 ++
 tests/general/bug-193.xsl |   11 +++++++++++
 4 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/libxslt/transform.c b/libxslt/transform.c
index 9faaede..d5aaf74 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -4674,6 +4674,10 @@ xsltApplyImports(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
 
        ctxt->currentTemplateRule = oldCurTemplRule;
     }
+    else {
+        /* Use built-in templates. */
+        xsltDefaultProcessOneNode(ctxt, contextNode, NULL);
+    }
 }
 
 /**
diff --git a/tests/docs/bug-193.xml b/tests/docs/bug-193.xml
new file mode 100644
index 0000000..91dccb3
--- /dev/null
+++ b/tests/docs/bug-193.xml
@@ -0,0 +1 @@
+<root><test/></root>
diff --git a/tests/general/bug-193.out b/tests/general/bug-193.out
new file mode 100644
index 0000000..c859f01
--- /dev/null
+++ b/tests/general/bug-193.out
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<result>passed</result>
diff --git a/tests/general/bug-193.xsl b/tests/general/bug-193.xsl
new file mode 100644
index 0000000..9e5bc78
--- /dev/null
+++ b/tests/general/bug-193.xsl
@@ -0,0 +1,11 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
+
+<xsl:template match="root">
+    <result>
+        <xsl:apply-imports/>
+    </result>
+</xsl:template>
+
+<xsl:template match="test">passed</xsl:template>
+
+</xsl:stylesheet>


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