Fix importing of encoding from included stylesheets
authorNick Wellnhofer <wellnhofer@aevum.de>
Thu, 17 Sep 2009 08:57:22 +0000 (10:57 +0200)
committerDaniel Veillard <veillard@redhat.com>
Thu, 17 Sep 2009 08:57:22 +0000 (10:57 +0200)
* libxslt/transform.c: process encoding like other imported output
  properties
* tests/docs/Makefile.am tests/docs/bug-169.xml tests/general/Makefile.am
  tests/general/bug-169.*: add a specific regression test

libxslt/transform.c
tests/docs/Makefile.am
tests/docs/bug-169.xml [new file with mode: 0644]
tests/general/Makefile.am
tests/general/bug-169.imp [new file with mode: 0644]
tests/general/bug-169.out [new file with mode: 0644]
tests/general/bug-169.xsl [new file with mode: 0644]

index 3466469..ce0bf43 100644 (file)
@@ -3220,6 +3220,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
     const xmlChar *doctypePublic;
     const xmlChar *doctypeSystem;
     const xmlChar *version;
+    const xmlChar *encoding;
 
     if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL))
         return;
@@ -3509,6 +3510,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
     XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
     XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
     XSLT_GET_IMPORT_PTR(version, style, version)
+    XSLT_GET_IMPORT_PTR(encoding, style, encoding)
 
     if ((method != NULL) &&
        (!xmlStrEqual(method, (const xmlChar *) "xml"))) {
@@ -3568,8 +3570,8 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
 #endif
     }
     res->charset = XML_CHAR_ENCODING_UTF8;
-    if (style->encoding != NULL)
-       res->encoding = xmlStrdup(style->encoding);
+    if (encoding != NULL)
+       res->encoding = xmlStrdup(encoding);
     ctxt->output = res;
     ctxt->insert = (xmlNodePtr) res;
     xsltApplySequenceConstructor(ctxt, node, inst->children, NULL);
@@ -5836,6 +5838,7 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
     const xmlChar *doctypePublic;
     const xmlChar *doctypeSystem;
     const xmlChar *version;
+    const xmlChar *encoding;
     xsltStackElemPtr variables;
     xsltStackElemPtr vptr;
 
@@ -5909,6 +5912,7 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
     XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
     XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
     XSLT_GET_IMPORT_PTR(version, style, version)
+    XSLT_GET_IMPORT_PTR(encoding, style, encoding)
 
     if ((method != NULL) &&
        (!xmlStrEqual(method, (const xmlChar *) "xml")))
@@ -5997,8 +6001,8 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
 #endif
     }
     res->charset = XML_CHAR_ENCODING_UTF8;
-    if (style->encoding != NULL)
-        res->encoding = xmlStrdup(style->encoding);
+    if (encoding != NULL)
+        res->encoding = xmlStrdup(encoding);
     variables = style->variables;
 
     /*
index b10edca..4393739 100644 (file)
@@ -167,6 +167,7 @@ EXTRA_DIST =        \
        bug-166.xml \
        bug-167.xml \
        bug-168.xml \
+       bug-169.xml \
        character.xml \
        array.xml \
        items.xml
diff --git a/tests/docs/bug-169.xml b/tests/docs/bug-169.xml
new file mode 100644 (file)
index 0000000..69d62f2
--- /dev/null
@@ -0,0 +1 @@
+<doc/>
index 87b0ed2..5d5baf0 100644 (file)
@@ -176,6 +176,7 @@ EXTRA_DIST = \
     bug-166.out bug-166.xsl \
     bug-167.out bug-167.xsl \
     bug-168.out bug-168.xsl \
+    bug-169.out bug-169.xsl bug-169.imp \
     character.out character.xsl \
     character2.out character2.xsl \
     itemschoose.out itemschoose.xsl \
diff --git a/tests/general/bug-169.imp b/tests/general/bug-169.imp
new file mode 100644 (file)
index 0000000..2928f4b
--- /dev/null
@@ -0,0 +1,5 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:output encoding="iso-8859-1"/>
+
+</xsl:stylesheet>
diff --git a/tests/general/bug-169.out b/tests/general/bug-169.out
new file mode 100644 (file)
index 0000000..30f8fad
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<result attr="Fahrvergnügen"/>
diff --git a/tests/general/bug-169.xsl b/tests/general/bug-169.xsl
new file mode 100644 (file)
index 0000000..e34ad9e
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:import href="bug-169.imp"/>
+
+<xsl:template match="/">
+    <result attr="Fahrvergnügen"/>
+</xsl:template>
+
+</xsl:stylesheet>