2007-12-27 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Thu, 27 Dec 2007 14:40:40 +0000 (14:40 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Thu, 27 Dec 2007 14:40:40 +0000 (14:40 -0000)
* XslTransformTests.cs : added test for bug #349375. (Actually the
  previous checkin fixed bug #349375.)
  Added another notworking one inspired by the same bug.

svn path=/trunk/mcs/; revision=91940

mcs/class/System.XML/Test/System.Xml.Xsl/ChangeLog
mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs

index 3662017efa762ff42e1896b7a502ee3abeaa335b..3346a582311f9ccf4b9e8d6da1c7059d3f009fc8 100644 (file)
@@ -1,3 +1,9 @@
+2007-12-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XslTransformTests.cs : added test for bug #349375. (Actually the
+         previous checkin fixed bug #349375.)
+         Added another notworking one inspired by the same bug.
+
 2007-12-17  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XslTransformTests.cs : added test for bug #349111.
index 094f2ec220a790da3c1159293da21016ca70d157..5e2f31c857d7d37d127ea926090ca504ace6976e 100644 (file)
@@ -2062,5 +2062,112 @@ Services
                        string expected = "<yyy>Harry Potter</yyy><yyy>29.99</yyy>";
                        Assert.AreEqual (expected, sw.ToString ());
                }
+
+#if NET_2_0
+               [Test] // bug #349375
+               public void PreserveWhitespace ()
+               {
+                       XslCompiledTransform xslt = new XslCompiledTransform ();
+                       xslt.Load (new XmlTextReader (new StringReader (@"
+<xsl:stylesheet
+  version=""1.0""
+  xmlns:xsl=""http://www.w3.org/1999/XSL/Transform""
+  >
+  <xsl:output omit-xml-declaration='yes' />
+  <xsl:strip-space elements='*'/>
+  <xsl:preserve-space elements='p span'/>
+
+  <xsl:template name='foo'>
+    <xsl:for-each select='node()'>
+        <xsl:attribute name='yes-one-node'/>
+        <xsl:value-of select='.'/>
+    </xsl:for-each>
+    <xsl:if test='not(node())'>
+        <xsl:attribute name='not-node'/>
+        <xsl:value-of select='.'/>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match='p'>
+    <y>
+      <xsl:for-each select='child::node()[position()]'>
+        <xsl:choose>
+          <xsl:when test='name()=""span""'>
+              <t>
+                <xsl:call-template name='foo'/>
+              </t>
+          </xsl:when>
+        </xsl:choose>
+      </xsl:for-each>
+    </y>
+  </xsl:template>
+
+</xsl:stylesheet>")));
+                       StringWriter sw = new StringWriter ();
+                       xslt.Transform (new XmlTextReader (new StringReader (@"
+<root>
+  <l0>
+    <p>
+      <span>1</span>
+      <span> </span>
+    </p>
+  </l0>
+</root>")), null, sw);
+                       Assert.AreEqual (@"<y><t yes-one-node="""">1</t><t yes-one-node=""""> </t></y>", sw.ToString ());
+               }
+
+               [Test] // reverse case of #349375
+               [Category ("NotWorking")]
+               public void PreserveWhitespace2 ()
+               {
+                       XslCompiledTransform xslt = new XslCompiledTransform ();
+                       xslt.Load (new XmlTextReader (new StringReader (@"
+<xsl:stylesheet
+  version=""1.0""
+  xmlns:xsl=""http://www.w3.org/1999/XSL/Transform""
+  >
+  <xsl:output omit-xml-declaration='yes' />
+  <xsl:preserve-space elements='*'/>
+  <xsl:strip-space elements='p span'/>
+
+  <xsl:template name='foo'>
+    <xsl:for-each select='node()'>
+        <xsl:attribute name='yes-one-node'/>
+        <xsl:value-of select='.'/>
+    </xsl:for-each>
+    <xsl:if test='not(node())'>
+        <xsl:attribute name='not-node'/>
+        <xsl:value-of select='.'/>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match='p'>
+    <y>
+      <xsl:for-each select='child::node()[position()]'>
+        <xsl:choose>
+          <xsl:when test='name()=""span""'>
+              <t>
+                <xsl:call-template name='foo'/>
+              </t>
+          </xsl:when>
+        </xsl:choose>
+      </xsl:for-each>
+    </y>
+  </xsl:template>
+
+</xsl:stylesheet>")));
+                       StringWriter sw = new StringWriter ();
+                       xslt.Transform (new XmlTextReader (new StringReader (@"
+<root>
+  <l0>
+    <p>
+      <span>1</span>
+      <span> </span>
+    </p>
+  </l0>
+</root>")), null, sw);
+                       Assert.AreEqual (@"<y><t yes-one-node="""">1</t><t not-node=""""></t></y>", sw.ToString ());
+               }
+#endif
        }
 }