2 // System.Xml.Xsl.XslTransformTests.cs
5 // Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
7 // (C) 2002 Atsushi Enomoto
12 using System.Xml.XPath;
14 using NUnit.Framework;
16 namespace MonoTests.System.Xml.Xsl
19 public class XslTransformTests : Assertion
26 public void GetReady()
28 doc = new XmlDocument ();
29 xslt = new XslTransform ();
30 result = new XmlDocument ();
34 public void TestBasicTransform ()
36 doc.LoadXml ("<root/>");
37 xslt.Load ("Test/XmlFiles/xsl/empty.xsl");
38 xslt.Transform ("Test/XmlFiles/xsl/empty.xsl", "Test/XmlFiles/xsl/result.xml");
39 result.Load ("Test/XmlFiles/xsl/result.xml");
40 AssertEquals ("count", 2, result.ChildNodes.Count);
44 [ExpectedException (typeof (XsltCompileException))]
45 public void InvalidStylesheet ()
47 XmlDocument doc = new XmlDocument ();
48 doc.LoadXml ("<xsl:element xmlns:xsl='http://www.w3.org/1999/XSL/Transform' />");
49 XslTransform t = new XslTransform ();
54 [ExpectedException (typeof (XsltCompileException))]
55 public void EmptyStylesheet ()
57 XmlDocument doc = new XmlDocument ();
58 XslTransform t = new XslTransform ();
63 [ExpectedException (typeof (XsltCompileException))]
64 public void InvalidStylesheet2 ()
66 string xml = @"<root>text</root>";
67 string xsl = @"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
68 <xsl:template match='/root'>
69 <xsl:call-template name='foo'>
70 <xsl:with-param name='name' value='text()' />
73 <xsl:template name='foo'>
74 <xsl:param name='name' />
77 <xsl:variable name='last' value='text()' />
78 <xsl:value-of select='$last' />
84 XslTransform xslt = new XslTransform ();
85 xslt.Load (new XPathDocument (new XmlTextReader (xsl, XmlNodeType.Document, null)));