[System.XML] Add unit test for XSL value-of bug (#18113)
authorDamien Daspit <damien_daspit@sil.org>
Tue, 4 Mar 2014 08:22:18 +0000 (15:22 +0700)
committerEberhard Beilharz <eb1@sil.org>
Mon, 17 Mar 2014 15:22:34 +0000 (16:22 +0100)
mcs/class/System.XML/Test/System.Xml.Xsl/XslCompiledTransformTests.cs

index cc8319a1f5eb3c1bb17f0869dda1443d6bbf28a4..284f213e6d7ef5d2834218640a8eab95ba5d9f53 100644 (file)
@@ -77,5 +77,36 @@ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-micros
                        // should transform without an exception
                        t.Transform (new XPathDocument (new XmlTextReader (new StringReader ("<root><foo attr='A'/><foo attr='B'/><foo attr='C'/></root>"))), null, sw);
                }
+
+               [Test]
+               public void ValueOfElementWithInsignificantWhitespace ()
+               {
+                       string xsl = @"<?xml version='1.0' encoding='utf-8'?>
+<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
+<xsl:template match='/'>
+       <root>
+               <bar>
+                       <xsl:if test='root/@attr'>
+                               <xsl:value-of select='root/@attr'>
+                               </xsl:value-of>
+                       </xsl:if>
+               </bar>
+               <baz>
+                       <xsl:for-each select='root/foo'>
+                               <xsl:if test='position() != 1'>
+                                       <xsl:text>,</xsl:text>
+                               </xsl:if>
+                               <xsl:value-of select='name(.)' />: <xsl:value-of select='@attr' />
+                       </xsl:for-each>
+               </baz>
+       </root>
+</xsl:template>
+</xsl:stylesheet>";
+                       StringWriter sw = new StringWriter ();
+                       XslCompiledTransform t = new XslCompiledTransform ();
+                       t.Load (new XmlTextReader(new StringReader(xsl)));
+                       t.Transform (new XPathDocument (new XmlTextReader (new StringReader ("<root attr='D'><foo attr='A'/><foo attr='B'/><foo attr='C'/></root>"))), null, sw);
+                       Assert.AreEqual ("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><bar>D</bar><baz>foo: A,foo: B,foo: C</baz></root>", sw.ToString ());
+               }
        }
 }