applied patch from Shaun McCance to fix bug #117616 about EXST
authorDaniel Veillard <veillard@src.gnome.org>
Thu, 24 Jul 2003 18:41:50 +0000 (18:41 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Thu, 24 Jul 2003 18:41:50 +0000 (18:41 +0000)
* libexslt/strings.c: applied patch from Shaun McCance to fix bug
  #117616 about EXST str:tokenize.
* tests/exslt/strings/Makefile.am tests/exslt/strings/tokenize.3.*:
  added the test in the regression suite.
Daniel

ChangeLog
libexslt/strings.c
tests/exslt/strings/Makefile.am
tests/exslt/strings/tokenize.3.out [new file with mode: 0644]
tests/exslt/strings/tokenize.3.xml [new file with mode: 0644]
tests/exslt/strings/tokenize.3.xsl [new file with mode: 0644]

index 72cb1c1..d3bbf3c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Jul 24 19:38:56 IST 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/strings.c: applied patch from Shaun McCance to fix bug
+         #117616 about EXST str:tokenize.
+       * tests/exslt/strings/Makefile.am tests/exslt/strings/tokenize.3.*:
+         added the test in the regression suite.
+
 Wed Jul 23 21:57:39 IST 2003 Daniel Veillard <daniel@veillard.com>
 
        * xsltproc/xsltproc.c: applying a patch based on #117377
index 1c799cf..6ddbc5e 100644 (file)
@@ -79,6 +79,7 @@ exsltStrTokenizeFunction(xmlXPathParserContextPtr ctxt, int nargs)
                     if (*cur == *delimiter) {
                         if (cur == token) {
                             /* discard empty tokens */
+                            token = cur + 1;
                             break;
                         }
                         *cur = 0;
@@ -92,10 +93,12 @@ exsltStrTokenizeFunction(xmlXPathParserContextPtr ctxt, int nargs)
                     }
                 }
             }
-            node =
-                xmlNewChild((xmlNodePtr) container, NULL,
-                            (const xmlChar *) "token", token);
-           xmlXPathNodeSetAddUnique(ret->nodesetval, node);
+            if (token != cur) {
+                node =
+                    xmlNewChild((xmlNodePtr) container, NULL,
+                                (const xmlChar *) "token", token);
+               xmlXPathNodeSetAddUnique(ret->nodesetval, node);
+            }
         }
     }
 
index 5ccb5a8..7612522 100644 (file)
@@ -6,6 +6,7 @@ $(top_builddir)/xsltproc/xsltproc:
 EXTRA_DIST =                                           \
        tokenize.1.xml tokenize.1.xsl tokenize.1.out    \
        tokenize.2.xml tokenize.2.xsl tokenize.2.out    \
+       tokenize.3.xml tokenize.3.xsl tokenize.3.out    \
        split.1.xml split.1.xsl split.1.out
 
 all:
diff --git a/tests/exslt/strings/tokenize.3.out b/tests/exslt/strings/tokenize.3.out
new file mode 100644 (file)
index 0000000..539a2fb
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+/foo/bar
+ 'foo'
+ 'bar'
+//foo/bar
+ 'foo'
+ 'bar'
+foo//bar
+ 'foo'
+ 'bar'
+foo/bar/
+ 'foo'
+ 'bar'
+foo/bar//
+ 'foo'
+ 'bar'
+
diff --git a/tests/exslt/strings/tokenize.3.xml b/tests/exslt/strings/tokenize.3.xml
new file mode 100644 (file)
index 0000000..9d5c293
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:str="http://exslt.org/strings"
+                version="1.0">
+
+<xsl:template match="/">
+       <xsl:for-each select="//string">
+               <xsl:text><xsl:value-of select="text()"/></xsl:text>
+               <xsl:for-each select="str:tokenize(text(), '/')">
+                           <xsl:text>   '</xsl:text>
+                           <xsl:value-of select="."/>
+                           <xsl:text>'</xsl:text>
+               </xsl:for-each>
+       </xsl:for-each>
+</xsl:template>
+
+<xsl:template name="foobar">
+       <string>/foo/bar</string>
+       <string>//foo/bar</string>
+       <string>foo//bar</string>
+       <string>foo/bar/</string>
+       <string>foo/bar//</string>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/tests/exslt/strings/tokenize.3.xsl b/tests/exslt/strings/tokenize.3.xsl
new file mode 100644 (file)
index 0000000..2ea6b12
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:str="http://exslt.org/strings"
+                version="1.0">
+
+<xsl:template match="/">
+       <xsl:for-each select="//string">
+               <xsl:value-of select="text()"/>
+               <xsl:text>
+</xsl:text>
+               <xsl:for-each select="str:tokenize(text(), '/')">
+                           <xsl:text> '</xsl:text>
+                           <xsl:value-of select="."/>
+                           <xsl:text>'
+</xsl:text>
+               </xsl:for-each>
+       </xsl:for-each>
+</xsl:template>
+
+<xsl:template name="foobar">
+       <string>/foo/bar</string>
+       <string>//foo/bar</string>
+       <string>foo//bar</string>
+       <string>foo/bar/</string>
+       <string>foo/bar//</string>
+</xsl:template>
+
+</xsl:stylesheet>