2005-09-10 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Sat, 10 Sep 2005 16:37:05 +0000 (16:37 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Sat, 10 Sep 2005 16:37:05 +0000 (16:37 -0000)
* 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

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

index d419ff209ac06f191a3ffa620a74206b457bd783..f342143179c76c8b3bcd47c6fbd195c395a00aa3 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Compiler.cs : (Compile) check children only when it is the document
+         element. Fixed bug #76046.
+
 2005-08-25  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ScriptCompilerInfo.cs : It should not be "#line" when the source is
index 57b80b88218f1c20e86d309feb8a57976ea509c6..1b9f817213463b684c7e62178a94d6ddbf90a390 100644 (file)
@@ -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 ("");
index 2964d183f6b25e523a07dfaf8bc95267d335620b..e926c80481fe89330ec7f44999977e08c60f4c2e 100644 (file)
@@ -1,3 +1,7 @@
+2005-09-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XslTransformTests.cs : added testcase for bug #76046.
+
 2005-08-31  Sebastien Pouliot  <sebastien@ximian.com>
 
        * XsltArgumentListCas.cs: New. CAS unit tests for AddExtensionObject.
index 030342049cdf50ec3c07c1f1c7984768f86f0140..67587fcbb2252b02174c9ec7b896f85b515c8a0a 100644 (file)
@@ -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);
+               }
        }
 }