[xslt] [PATCH] xsl:strip-space with namespace and wildcard
- From: Nick Wellnhofer <wellnhofer aevum de>
- To: The Gnome XSLT library mailing-list <xslt gnome org>
- Subject: [xslt] [PATCH] xsl:strip-space with namespace and wildcard
- Date: Mon, 17 Nov 2008 16:59:03 +0100
xsl:strip-space doesn't work if there is a NameTest with a namespace and
a wildcard, i.e. something like:
<xsl:strip-space elements="foo:*"/>
Attached is a patch against trunk with a fix and some test cases.
Nick
--
aevum gmbh
rumfordstr. 4
80469 münchen
germany
tel: +49 89 3838 0653
http://aevum.de/
Index: tests/REC/test-3.4-2.xsl
===================================================================
--- tests/REC/test-3.4-2.xsl (revision 0)
+++ tests/REC/test-3.4-2.xsl (revision 0)
@@ -0,0 +1,11 @@
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:foo1="urn:foo1"
+ xmlns:foo2="urn:foo2"
+>
+ <xsl:strip-space elements="foo1:*"/>
+ <xsl:template match="doc">
+ <xsl:apply-templates select="*/*"/>
+ </xsl:template>
+</xsl:stylesheet>
Index: tests/REC/test-3.4-2.out
===================================================================
--- tests/REC/test-3.4-2.out (revision 0)
+++ tests/REC/test-3.4-2.out (revision 0)
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+ test01 test02 test11test12 test11 test12
Index: tests/REC/test-3.4-2.xml
===================================================================
--- tests/REC/test-3.4-2.xml (revision 0)
+++ tests/REC/test-3.4-2.xml (revision 0)
@@ -0,0 +1,15 @@
+<doc>
+ <container>
+ <element1> <child>test01</child> </element1>
+ <element2> <child>test02</child> </element2>
+ </container>
+ <foo1:container xmlns:foo1="urn:foo1">
+ <foo1:element1> <foo1:child>test11</foo1:child> </foo1:element1>
+ <foo1:element2> <foo1:child>test12</foo1:child> </foo1:element2>
+ </foo1:container>
+ <foo2:container xmlns:foo2="urn:foo2">
+ <foo2:element1> <foo2:child>test11</foo2:child> </foo2:element1>
+ <foo2:element2> <foo2:child>test12</foo2:child> </foo2:element2>
+ </foo2:container>
+</doc>
+
Index: tests/REC/Makefile.am
===================================================================
--- tests/REC/Makefile.am (revision 1493)
+++ tests/REC/Makefile.am (working copy)
@@ -21,6 +21,9 @@
test-2.3-2.out test-2.3-2.xml test-2.3-2.xsl \
test-2.5-1.out test-2.5-1.xml test-2.5-1.xsl test-2.5-1.err \
test-2.6.2-1.out test-2.6.2-1.xml test-2.6.2-1.xsl \
+ test-3.4-1.out test-3.4-1.xml test-3.4-1.xsl \
+ test-3.4-2.out test-3.4-2.xml test-3.4-2.xsl \
+ test-3.4-3.out test-3.4-3.xml test-3.4-3.xsl \
test-5.2-1.out test-5.2-1.xml test-5.2-1.xsl \
test-5.2-2.out test-5.2-2.xml test-5.2-2.xsl \
test-5.2-3.out test-5.2-3.xml test-5.2-3.xsl \
Index: tests/REC/test-3.4-1.xsl
===================================================================
--- tests/REC/test-3.4-1.xsl (revision 0)
+++ tests/REC/test-3.4-1.xsl (revision 0)
@@ -0,0 +1,11 @@
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:foo1="urn:foo1"
+ xmlns:foo2="urn:foo2"
+>
+ <xsl:strip-space elements="foo1:element1"/>
+ <xsl:template match="doc">
+ <xsl:apply-templates select="*/*"/>
+ </xsl:template>
+</xsl:stylesheet>
Index: tests/REC/test-3.4-1.out
===================================================================
--- tests/REC/test-3.4-1.out (revision 0)
+++ tests/REC/test-3.4-1.out (revision 0)
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+ test01 test02 test11 test12 test11 test12
Index: tests/REC/test-3.4-3.xsl
===================================================================
--- tests/REC/test-3.4-3.xsl (revision 0)
+++ tests/REC/test-3.4-3.xsl (revision 0)
@@ -0,0 +1,11 @@
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:foo1="urn:foo1"
+ xmlns:foo2="urn:foo2"
+>
+ <xsl:strip-space elements="*"/>
+ <xsl:template match="doc">
+ <xsl:apply-templates select="*/*"/>
+ </xsl:template>
+</xsl:stylesheet>
Index: tests/REC/test-3.4-3.out
===================================================================
--- tests/REC/test-3.4-3.out (revision 0)
+++ tests/REC/test-3.4-3.out (revision 0)
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+test01test02test11test12test11test12
Index: tests/REC/test-3.4-1.xml
===================================================================
--- tests/REC/test-3.4-1.xml (revision 0)
+++ tests/REC/test-3.4-1.xml (revision 0)
@@ -0,0 +1,15 @@
+<doc>
+ <container>
+ <element1> <child>test01</child> </element1>
+ <element2> <child>test02</child> </element2>
+ </container>
+ <foo1:container xmlns:foo1="urn:foo1">
+ <foo1:element1> <foo1:child>test11</foo1:child> </foo1:element1>
+ <foo1:element2> <foo1:child>test12</foo1:child> </foo1:element2>
+ </foo1:container>
+ <foo2:container xmlns:foo2="urn:foo2">
+ <foo2:element1> <foo2:child>test11</foo2:child> </foo2:element1>
+ <foo2:element2> <foo2:child>test12</foo2:child> </foo2:element2>
+ </foo2:container>
+</doc>
+
Index: tests/REC/test-3.4-3.xml
===================================================================
--- tests/REC/test-3.4-3.xml (revision 0)
+++ tests/REC/test-3.4-3.xml (revision 0)
@@ -0,0 +1,15 @@
+<doc>
+ <container>
+ <element1> <child>test01</child> </element1>
+ <element2> <child>test02</child> </element2>
+ </container>
+ <foo1:container xmlns:foo1="urn:foo1">
+ <foo1:element1> <foo1:child>test11</foo1:child> </foo1:element1>
+ <foo1:element2> <foo1:child>test12</foo1:child> </foo1:element2>
+ </foo1:container>
+ <foo2:container xmlns:foo2="urn:foo2">
+ <foo2:element1> <foo2:child>test11</foo2:child> </foo2:element1>
+ <foo2:element2> <foo2:child>test12</foo2:child> </foo2:element2>
+ </foo2:container>
+</doc>
+
Index: libxslt/imports.c
===================================================================
--- libxslt/imports.c (revision 1493)
+++ libxslt/imports.c (working copy)
@@ -348,6 +348,10 @@
if (node->ns != NULL) {
val = (const xmlChar *)
xmlHashLookup2(style->stripSpaces, node->name, node->ns->href);
+ if (val == NULL) {
+ val = (const xmlChar *)
+ xmlHashLookup2(style->stripSpaces, "*", node->ns->href);
+ }
} else {
val = (const xmlChar *)
xmlHashLookup2(style->stripSpaces, node->name, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]