+2004-03-13 Atsushi Enomoto <atsushi@ximian.com>
+
+ * Compiler.cs,
+ XslStylesheet.cs : Reject xsl element other than stylesheet and
+ transform. Check mandatory version attribute (only for existence).
+
2004-03-07 Atsushi Enomoto <atsushi@ximian.com>
* MSXslScriptManager.cs : if extension namespace was not found in
this.res = new XmlUrlResolver ();
this.evidence = evidence;
- if (!nav.MoveToFirstChild ()) throw new Exception ("WTF?");
+ if (!nav.MoveToFirstChild ())
+ throw new XsltCompileException ("Stylesheet root element must be either \"stylesheet\" or \"transform\" or any literal element.", null, nav);
outputs [""] = new XslOutput ("");
//
using System;
-using System.CodeDom;
using System.Collections;
using System.Collections.Specialized;
using System.Xml;
c.PushStylesheet (this);
templates = new XslTemplateTable (this);
+
+ // move to root element
+ while (c.Input.NodeType != XPathNodeType.Element)
+ if (!c.Input.MoveToNext ())
+ throw new XsltCompileException ("Stylesheet root element must be either \"stylesheet\" or \"transform\" or any literal element.", null, c.Input);
+
if (c.Input.NamespaceURI != XsltNamespace) {
// then it is simplified stylesheet.
Templates.Add (new XslTemplate (c));
} else {
+ if (c.Input.LocalName != "stylesheet" &&
+ c.Input.LocalName != "transform")
+ throw new XsltCompileException ("Stylesheet root element must be either \"stylesheet\" or \"transform\" or any literal element.", null, c.Input);
+
version = c.Input.GetAttribute ("version", "");
+ if (version == null)
+ throw new XsltCompileException ("Mandatory attribute version is missing.", null, c.Input);
+
extensionElementPrefixes = c.ParseQNameListAttribute ("extension-element-prefixes");
excludeResultPrefixes = c.ParseQNameListAttribute ("exclude-result-prefixes");
if (c.Input.MoveToFirstNamespace (XPathNamespaceScope.Local)) {