fixing the bug #120971 on cdata-section-elements with namespaced names
authorDaniel Veillard <veillard@src.gnome.org>
Fri, 29 Aug 2003 10:30:41 +0000 (10:30 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Fri, 29 Aug 2003 10:30:41 +0000 (10:30 +0000)
* libxslt/transform.c: fixing the bug #120971 on cdata-section-elements
  with namespaced names reported by Steve Hay
* tests/docs/Makefile.am tests/docs/bug-129.*
  tests/general/Makefile.am tests/general/bug-129*: added the
  test to the regression suite for this bug.
Daniel

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

index 499ce97..0baad8b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Aug 29 12:28:12 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixing the bug #120971 on cdata-section-elements
+         with namespaced names reported by Steve Hay
+       * tests/docs/Makefile.am tests/docs/bug-129.*
+         tests/general/Makefile.am tests/general/bug-129*: added the
+         test to the regression suite for this bug.
+
 Thu Aug 28 18:30:11 CEST 2003 Igor Zlatkovic <igor@zlatkovic.com>
 
        * libxslt/xsltexports.h libexslt/exsltexports.h: fixed typos reported by
index 59c9449..4f2ec93 100644 (file)
@@ -558,9 +558,13 @@ xsltCopyTextString(xsltTransformContextPtr ctxt, xmlNodePtr target,
     len = xmlStrlen(string);
     if ((ctxt->type == XSLT_OUTPUT_XML) &&
        (ctxt->style->cdataSection != NULL) &&
-       (target != NULL) &&
-       (xmlHashLookup(ctxt->style->cdataSection,
-                      target->name) != NULL)) {
+       (target != NULL) && (target->type == XML_ELEMENT_NODE) &&
+       (((target->ns == NULL) && 
+         (xmlHashLookup2(ctxt->style->cdataSection,
+                         target->name, NULL) != NULL)) ||
+        ((target->ns != NULL) &&
+         (xmlHashLookup2(ctxt->style->cdataSection,
+                         target->name, target->ns->href) != NULL)))) {
        if ((target != NULL) && (target->last != NULL) &&
            (target->last->type == XML_CDATA_SECTION_NODE)) {
            return(xsltAddTextString(ctxt, target->last, string, len));
@@ -634,9 +638,13 @@ xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target,
 
     if ((ctxt->type == XSLT_OUTPUT_XML) &&
        (ctxt->style->cdataSection != NULL) &&
-       (target != NULL) &&
-       (xmlHashLookup(ctxt->style->cdataSection,
-                      target->name) != NULL)) {
+       (target != NULL) && (target->type == XML_ELEMENT_NODE) &&
+       (((target->ns == NULL) && 
+         (xmlHashLookup2(ctxt->style->cdataSection,
+                         target->name, NULL) != NULL)) ||
+        ((target->ns != NULL) &&
+         (xmlHashLookup2(ctxt->style->cdataSection,
+                         target->name, target->ns->href) != NULL)))) {
        copy = xmlNewCDataBlock(ctxt->output, cur->content,
                                xmlStrlen(cur->content));
        ctxt->lasttext = NULL;
index cf40b49..ffaae2e 100644 (file)
@@ -128,6 +128,7 @@ EXTRA_DIST =        \
        bug-126.xml \
        bug-127.xml \
        bug-128.xml \
+       bug-129.xml \
        character.xml \
        array.xml \
        items.xml
diff --git a/tests/docs/bug-129.xml b/tests/docs/bug-129.xml
new file mode 100644 (file)
index 0000000..2ec6d99
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<root xmlns:foo="http://foo.org">
+  <foo:elt>
+    <![CDATA[>]]>
+  </foo:elt>
+</root>
index 300235a..d3fafa9 100644 (file)
@@ -133,6 +133,7 @@ EXTRA_DIST = \
     bug-126.out bug-126.xsl \
     bug-127.out bug-127.xsl \
     bug-128.out bug-128.xsl \
+    bug-129.out bug-129.xsl \
     character.out character.xsl \
     character2.out character2.xsl \
     itemschoose.out itemschoose.xsl \
diff --git a/tests/general/bug-129.out b/tests/general/bug-129.out
new file mode 100644 (file)
index 0000000..7970b7c
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<root xmlns:foo="http://foo.org">
+  <foo:elt><![CDATA[
+    >
+  ]]></foo:elt>
+</root>
diff --git a/tests/general/bug-129.xsl b/tests/general/bug-129.xsl
new file mode 100644 (file)
index 0000000..52f0afc
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="http://foo.org">
+  <xsl:output cdata-section-elements="foo:elt"/>
+  <xsl:template match="@*|node()">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|node()"/>
+    </xsl:copy>
+  </xsl:template>
+</xsl:stylesheet>