[xslt] [PATCH] Imported encoding not set on result document




If there is a xsl:output with an encoding attribute in an imported stylesheet, the encoding is not set on the result document. This causes all non-ASCII characters in attributes to be replaced with numeric entities.

Attached is a patch against trunk with a fix.

Nick


--
aevum gmbh
rumfordstr. 4
80469 münchen
germany

tel: +49 89 3838 0653
http://aevum.de/
Index: libxslt/transform.c
===================================================================
--- libxslt/transform.c	(revision 1493)
+++ libxslt/transform.c	(working copy)
@@ -3217,6 +3217,7 @@
     const xmlChar *doctypePublic;
     const xmlChar *doctypeSystem;
     const xmlChar *version;
+    const xmlChar *encoding;
 
     if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL))
         return;
@@ -3506,6 +3507,7 @@
     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"))) {
@@ -3565,8 +3567,8 @@
 #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);
@@ -5833,6 +5835,7 @@
     const xmlChar *doctypePublic;
     const xmlChar *doctypeSystem;
     const xmlChar *version;
+    const xmlChar *encoding;
     xsltStackElemPtr variables;
     xsltStackElemPtr vptr;
 
@@ -5904,6 +5907,7 @@
     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")))
@@ -5992,8 +5996,8 @@
 #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;
 
     /*


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