I'm gonna change my nick to FlyTox at some point ...:
authorDaniel Veillard <veillard@src.gnome.org>
Wed, 7 Mar 2001 17:05:56 +0000 (17:05 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Wed, 7 Mar 2001 17:05:56 +0000 (17:05 +0000)
 - imports.c transform.c xslt.c xsltInternals.h: fixed a
   strip-spaces problem
 - tests/docs/*.xml tests/general/*.[xsl,out]: added reported
   bugs to testsuite
Daniel

18 files changed:
ChangeLog
libxslt/imports.c
libxslt/transform.c
libxslt/xslt.c
libxslt/xsltInternals.h
tests/Makefile.am
tests/docs/bug-1-.xml [new file with mode: 0644]
tests/docs/bug-2-.xml [new file with mode: 0644]
tests/docs/character.xml [new file with mode: 0644]
tests/general/bug-1-.out [new file with mode: 0644]
tests/general/bug-1-.xsl [new file with mode: 0644]
tests/general/bug-2-.out [new file with mode: 0644]
tests/general/bug-2-.xsl [new file with mode: 0644]
tests/general/character.out [new file with mode: 0644]
tests/general/character.xsl [new file with mode: 0644]
tests/general/character2.out [new file with mode: 0644]
tests/general/character2.xsl [new file with mode: 0644]
tests/general/itemschoose.out.out [new file with mode: 0644]

index 68d167e..d61b3b7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Mar  7 18:01:07 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+        * imports.c transform.c xslt.c xsltInternals.h: fixed a
+          strip-spaces problem
+        * tests/docs/*.xml tests/general/*.[xsl,out]: added reported
+          bugs to testsuite
+
 Wed Mar  7 13:34:13 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
        * libxslt/transform.[ch]: finished integrating the current
index e4e2799..15e80a4 100644 (file)
@@ -219,13 +219,9 @@ xsltFindElemSpaceHandling(xsltTransformContextPtr ctxt, xmlNodePtr node) {
            if (xmlStrEqual(val, (xmlChar *) "preserve"))
                return(0);
        } 
-       val = (const xmlChar *)
-             xmlHashLookup(ctxt->style->stripSpaces,
-                           (const xmlChar *)"*");
-       if ((val != NULL) &&
-           (xmlStrEqual(val, (xmlChar *) "strip")))
+       if (ctxt->style->stripAll == 1)
            return(1);
-       if (xmlStrEqual(val, (xmlChar *) "preserve"))
+       if (ctxt->style->stripAll == -1)
            return(0);
 
        style = xsltNextImport(style);
index 001fb69..239860e 100644 (file)
@@ -680,6 +680,30 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
     xsltTemplatePtr template;
     xmlNodePtr oldNode;
 
+    /*
+     * Cleanup children empty nodes if asked for
+     */
+    if ((node->children != NULL) &&
+       (xsltFindElemSpaceHandling(ctxt, node))) {
+       xmlNodePtr delete = NULL, cur = node->children;
+
+       while (cur != NULL) {
+           if (IS_BLANK_NODE(cur))
+               delete = cur;
+           
+            cur = cur->next;
+           if (delete != NULL) {
+#ifdef DEBUG_PROCESS
+               xsltGenericDebug(xsltGenericDebugContext,
+            "xsltDefaultProcessOneNode: removing ignorable blank node\n");
+#endif
+               xmlUnlinkNode(delete);
+               xmlFreeNode(delete);
+               delete = NULL;
+           }
+       }
+    }
+
     template = xsltGetTemplate(ctxt, node, NULL);
     /*
      * If no template is found, apply the default rule.
index 5fd14a9..b30a1fc 100644 (file)
@@ -622,7 +622,11 @@ xsltParseStylesheetPreserveSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
            xsltGenericDebug(xsltGenericDebugContext,
                "add preserved space element %s\n", element);
 #endif
-           xmlHashAddEntry(style->stripSpaces, element, "preserve");
+           if (xmlStrEqual(element, (const xmlChar *)"*")) {
+               style->stripAll = -1;
+           } else {
+               xmlHashAddEntry(style->stripSpaces, element, "preserve");
+           }
            xmlFree(element);
        }
        element = end;
@@ -635,7 +639,7 @@ xsltParseStylesheetPreserveSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
  * @style:  the XSLT stylesheet
  * @template:  the "strip-space" prefix
  *
- * parse an XSLT stylesheet strip-space prefix and record
+ * parse an XSLT stylesheet extension prefix and record
  * prefixes needing stripping
  */
 
@@ -728,7 +732,11 @@ xsltParseStylesheetStripSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
            xsltGenericDebug(xsltGenericDebugContext,
                "add stripped space element %s\n", element);
 #endif
-           xmlHashAddEntry(style->stripSpaces, element, "strip");
+           if (xmlStrEqual(element, (const xmlChar *)"*")) {
+               style->stripAll = 1;
+           } else {
+               xmlHashAddEntry(style->stripSpaces, element, "strip");
+           }
            xmlFree(element);
        }
        element = end;
index 48e6c1a..06871b6 100644 (file)
@@ -120,6 +120,7 @@ struct _xsltStylesheet {
     xmlDocPtr doc;             /* the parsed XML stylesheet */
     xmlHashTablePtr stripSpaces;/* the hash table of the strip-space
                                   preserve space and cdata-section elements */
+    int             stripAll;  /* strip-space * (1) preserve-space * (-1) */
 
     /*
      * Global variable or parameters
index dbcefad..d360190 100644 (file)
@@ -1,6 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS=docs REC1 REC2 REC general namespaces numbers documents xmlspec docbook
+SUBDIRS=docs REC1 REC2 REC general namespaces numbers documents \
+        xmlspec docbook
 
 all:
 
diff --git a/tests/docs/bug-1-.xml b/tests/docs/bug-1-.xml
new file mode 100644 (file)
index 0000000..cc677f7
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<foo>
+        <bar>This is bar 1</bar>
+        <xxx/>
+        <bar>This is bar 2</bar>
+</foo>
+
diff --git a/tests/docs/bug-2-.xml b/tests/docs/bug-2-.xml
new file mode 100644 (file)
index 0000000..94879b0
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<foo>
+  <bar>
+    This is bar 1
+  </bar>
+  <bar>
+    This is bar 2
+  </bar>
+  <bar>
+    This is bar 3
+  </bar>
+</foo>
diff --git a/tests/docs/character.xml b/tests/docs/character.xml
new file mode 100644 (file)
index 0000000..815e967
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<character>
+  <skills>
+    <skill name="Balance" base="dex" ranks="2" total="5" mod="3"/>
+    <skill name="Bluff" base="cha" ranks="3" total="4" mod="1"/>
+    <skill name="Climb" base="str" ranks="6" total="5" mod="-1"/>
+    <skill name="Diplomacy" base="cha" ranks="2" total="3" mod="1"/>
+    <skill name="Escape artist" base="dex" ranks="2" total="5" mod="3"/>
+    <skill name="Gather info" base="cha" ranks="2" total="3" mod="1"/>
+    <skill name="Hide" base="dex" ranks="2" total="5" mod="3"/>
+    <skill name="Jump" base="str" ranks="4" total="3" mod="-1"/>
+    <skill name="Listen" base="wis" ranks="2" total="3" mod="1"/>
+    <skill name="Move silently" base="dex" ranks="2" total="5" mod="3"/>
+    <skill name="Perform" base="cha" ranks="4" total="5" mod="1"/>
+    <skill name="Ride" base="dex" ranks="4" total="7" mod="3"/>
+    <skill name="Search" base="int" ranks="2" total="3" mod="1"/>
+    <skill name="Sense motive" base="wis" ranks="2" total="3" mod="1"/>
+    <skill name="Spot" base="wis" ranks="2" total="3" mod="1"/>
+    <skill name="Swim" base="str" ranks="4" total="3" mod="-1"/>
+    <skill name="Tumble" base="dex" ranks="3" total="6" mod="3"/>
+    <skill name="Use rope" base="dex" ranks="2" total="5" mod="3"/>
+  </skills>
+</character>
diff --git a/tests/general/bug-1-.out b/tests/general/bug-1-.out
new file mode 100644 (file)
index 0000000..bedd070
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<FOO>
+        <BAR>This is bar 1</BAR>
+        <XXX></XXX>
+        <BAR>This is bar 2</BAR>
+</FOO>
diff --git a/tests/general/bug-1-.xsl b/tests/general/bug-1-.xsl
new file mode 100644 (file)
index 0000000..4d7c87d
--- /dev/null
@@ -0,0 +1,21 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:template match="foo">
+        <FOO>
+                <xsl:apply-templates/>
+        </FOO>
+</xsl:template>
+
+<xsl:template match="bar">
+        <BAR>
+                <xsl:value-of select="."/>
+        </BAR>
+</xsl:template>
+
+<xsl:template match="xxx">
+        <XXX>
+                <xsl:value-of select="."/>
+        </XXX>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/tests/general/bug-2-.out b/tests/general/bug-2-.out
new file mode 100644 (file)
index 0000000..d047b75
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<FOO><BAR INDEX="1">
+    This is bar 1
+  </BAR><BAR INDEX="2">
+    This is bar 2
+  </BAR><BAR INDEX="3">
+    This is bar 3
+  </BAR></FOO>
diff --git a/tests/general/bug-2-.xsl b/tests/general/bug-2-.xsl
new file mode 100644 (file)
index 0000000..92f5d92
--- /dev/null
@@ -0,0 +1,16 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:strip-space elements="*"/>
+
+<xsl:template match="foo">
+  <FOO>
+    <xsl:apply-templates/>
+  </FOO>
+</xsl:template>
+
+<xsl:template match="bar">
+  <BAR INDEX="{position()}">
+    <xsl:value-of select="."/>
+  </BAR>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/tests/general/character.out b/tests/general/character.out
new file mode 100644 (file)
index 0000000..2ced81a
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+Balance Bluff Climb Diplomacy Escape artist Gather info Hide Jump Listen Move silently Perform Ride Search Sense motive Spot Swim Tumble Use rope 
diff --git a/tests/general/character.xsl b/tests/general/character.xsl
new file mode 100644 (file)
index 0000000..34eaa73
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+version="1.0">
+  <xsl:output method="xml" indent="yes"/>
+
+<xsl:template match="character">
+  <xsl:apply-templates select="skills"/>
+</xsl:template>
+
+<xsl:template match="skills">
+  <xsl:for-each select="./*">
+    <xsl:value-of select="./@name"/>
+    <xsl:text> </xsl:text>
+  </xsl:for-each>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/tests/general/character2.out b/tests/general/character2.out
new file mode 100644 (file)
index 0000000..2ced81a
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+Balance Bluff Climb Diplomacy Escape artist Gather info Hide Jump Listen Move silently Perform Ride Search Sense motive Spot Swim Tumble Use rope 
diff --git a/tests/general/character2.xsl b/tests/general/character2.xsl
new file mode 100644 (file)
index 0000000..c3ff26e
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+version="1.0">
+  <xsl:output method="xml" indent="yes"/>
+
+<xsl:template match="character">
+  <xsl:apply-templates select="skills"/>
+</xsl:template>
+
+<xsl:template match="skills">
+  <xsl:for-each select="*">
+    <xsl:value-of select="./@name"/>
+    <xsl:text> </xsl:text>
+  </xsl:for-each>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/tests/general/itemschoose.out.out b/tests/general/itemschoose.out.out
new file mode 100644 (file)
index 0000000..e69de29