Browse Source

2005-09-16 Atsushi Enomoto <[email protected]>

	* XslTransform.cs : When Transform() returns XmlReader, allow empty
	  results. Fixed bug #76115.

	* ScriptCompilerInfo.cs : Compile correct replacement result.
	  Fixed bug #76116.

	* XslTransformTests.cs : added testcase for bug #76115.
	* MSXslScriptTests.cs : added testcase for bug #76116.


svn path=/trunk/mcs/; revision=50132
Atsushi Eno 20 years ago
parent
commit
c365140073

+ 5 - 0
mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog

@@ -1,3 +1,8 @@
+2005-09-16  Atsushi Enomoto  <[email protected]>
+
+	* ScriptCompilerInfo.cs : Compile correct replacement result.
+	  Fixed bug #76116.
+
 2005-09-10  Atsushi Enomoto  <[email protected]>
 
 	* Compiler.cs : (Compile) check children only when it is the document

+ 1 - 1
mcs/class/System.XML/Mono.Xml.Xsl/ScriptCompilerInfo.cs

@@ -102,7 +102,7 @@ namespace Mono.Xml.Xsl
 				DateTime.Now.ToString (CultureInfo.InvariantCulture))
 				.Replace ("{1}", classSuffix)
 				.Replace ("{2}", code);
-			source = FormatSource (li, filename, code);
+			source = FormatSource (li, filename, source);
 
 			CompilerResults res = compiler.CompileAssemblyFromSource (parameters, source);
 			foreach (CompilerError err in res.Errors)

+ 5 - 0
mcs/class/System.XML/System.Xml.Xsl/ChangeLog

@@ -1,3 +1,8 @@
+2005-09-16  Atsushi Enomoto  <[email protected]>
+
+	* XslTransform.cs : When Transform() returns XmlReader, allow empty
+	  results. Fixed bug #76115.
+
 2005-08-31  Sebastien Pouliot  <[email protected]>
 
 	* XsltArgumentList.cs: Added a LinkDemand for Unrestricted on 

+ 1 - 1
mcs/class/System.XML/System.Xml.Xsl/XslTransform.cs

@@ -90,7 +90,7 @@ namespace System.Xml.Xsl {
 			MemoryStream stream = new MemoryStream ();
 			Transform (input, args, new XmlTextWriter (stream, null), resolver);
 			stream.Position = 0;
-			return new XmlTextReader (stream);
+			return new XmlTextReader (stream, XmlNodeType.Element, null);
 		}
 
 #if NET_1_1

+ 5 - 0
mcs/class/System.XML/Test/System.Xml.Xsl/ChangeLog

@@ -1,3 +1,8 @@
+2005-09-10  Atsushi Enomoto  <[email protected]>
+
+	* XslTransformTests.cs : added testcase for bug #76115.
+	* MSXslScriptTests.cs : added testcase for bug #76116.
+
 2005-09-10  Atsushi Enomoto  <[email protected]>
 
 	* XslTransformTests.cs : added testcase for bug #76046.

+ 25 - 0
mcs/class/System.XML/Test/System.Xml.Xsl/MsxslScriptTests.cs

@@ -188,5 +188,30 @@ namespace MonoTests.System.Xml.Xsl
 			xslt.Load (new XmlTextReader (script, XmlNodeType.Document, null));
 			xslt.Transform (doc.CreateNavigator (), null, new XmlTextWriter (TextWriter.Null));
 		}
+
+		[Test]
+		[Category ("NotWorking")] // it depends on "mcs" existence
+		public void CompileNoLineInfoSource ()
+		{
+			// bug #76116
+			string xslt = @"<xslt:stylesheet xmlns:xslt='http://www.w3.org/1999/XSL/Transform' version='1.0' xmlns:msxsl='urn:schemas-microsoft-com:xslt' xmlns:stringutils='urn:schemas-sourceforge.net-blah' xmlns:nant='unknown-at-this-time'>
+    <xslt:output method='text' />
+    <msxsl:script language='C#' implements-prefix='stringutils'>
+    <![CDATA[
+        string PadRight( string str, int padding) {
+            return str.PadRight(padding);
+        }
+    ]]>
+    </msxsl:script>
+    <xslt:template match='/'>
+        <foo/>
+    </xslt:template>
+</xslt:stylesheet>";
+			XmlDocument doc = new XmlDocument ();
+			doc.LoadXml (xslt);
+
+			XslTransform t = new XslTransform ();
+			t.Load (doc);
+		}
 	}
 }

+ 20 - 0
mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs

@@ -283,5 +283,25 @@ namespace MonoTests.System.Xml.Xsl
 			XmlNode node = doc.ChildNodes [0].ChildNodes [1];
 			xslt.Load (node, null, null);
 		}
+
+		[Test]
+		public void ReturnEmptyResultsAsXmlReader ()
+		{
+			// bug #76115
+			XmlDocument doc = new XmlDocument ();
+			doc.LoadXml ("<xsl:transform xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0' />");
+			XslTransform xslt = new XslTransform ();
+			xslt.Load (doc, null, null);
+			XmlReader reader = xslt.Transform(doc, null, new XmlUrlResolver ());
+			reader.Read ();
+
+			// another case - with xsl:output standalone='yes'
+			doc.LoadXml ("<xsl:transform xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0' ><xsl:output standalone='yes' indent='no'/><xsl:template match='/'><foo/></xsl:template></xsl:transform>");
+			xslt = new XslTransform ();
+			xslt.Load (doc, null, null);
+			reader = xslt.Transform (doc, null, new XmlUrlResolver ());
+			while (!reader.EOF)
+				reader.Read (); // btw no XMLdecl output.
+		}
 	}
 }