2
0
Эх сурвалжийг харах

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

	* Compiler.cs : (Compile) check children only when it is the document
	  element. Fixed bug #76046.

	* XslTransformTests.cs : added testcase for bug #76046.


svn path=/trunk/mcs/; revision=49867
Atsushi Eno 20 жил өмнө
parent
commit
fff44b81bc

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

@@ -1,3 +1,8 @@
+2005-09-10  Atsushi Enomoto  <[email protected]>
+
+	* Compiler.cs : (Compile) check children only when it is the document
+	  element. Fixed bug #76046.
+
 2005-08-25  Atsushi Enomoto  <[email protected]>
 
 	* ScriptCompilerInfo.cs : It should not be "#line" when the source is

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

@@ -137,7 +137,8 @@ namespace Mono.Xml.Xsl
 				this.res = new XmlUrlResolver ();
 			this.evidence = evidence;
 
-			if (!nav.MoveToFirstChild ())
+			// reject empty document.
+			if (nav.NodeType == XPathNodeType.Root && !nav.MoveToFirstChild ())
 				throw new XsltCompileException ("Stylesheet root element must be either \"stylesheet\" or \"transform\" or any literal element.", null, nav);
 				
 			outputs [""] = new XslOutput ("");

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

@@ -1,3 +1,7 @@
+2005-09-10  Atsushi Enomoto  <[email protected]>
+
+	* XslTransformTests.cs : added testcase for bug #76046.
+
 2005-08-31  Sebastien Pouliot  <[email protected]>
 
 	* XsltArgumentListCas.cs: New. CAS unit tests for AddExtensionObject.

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

@@ -272,5 +272,16 @@ namespace MonoTests.System.Xml.Xsl
 			XPathDocument xmlDocument = new XPathDocument (new StringReader (xmlText));
 			transform.Transform (xmlDocument, null, TextWriter.Null);
 		}
+
+		// bug #76046
+		[Test]
+		public void LoadStyleFromNonRoot ()
+		{
+			XmlDocument doc = new XmlDocument ();
+			XslTransform xslt = new XslTransform ();
+			doc.LoadXml ("<root><dummy /><xsl:transform xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0' /></root>");
+			XmlNode node = doc.ChildNodes [0].ChildNodes [1];
+			xslt.Load (node, null, null);
+		}
 	}
 }