private void HandleInclude(Compiler c) { XPathNavigator included = null; foreach (XPathNavigator inc in inProcessIncludes.Keys) { if (inc.IsSamePosition(c.Input)) { included = (XPathNavigator)inProcessIncludes [inc]; break; } } if (included == null) { throw new Exception("Should not happen. Current input is " + c.Input.BaseURI + " / " + c.Input.Name + ", " + inProcessIncludes.Count); } if (included.NodeType == XPathNodeType.Root) { return; // Already done. } c.PushInputDocument(included); included.MoveToRoot(); included.MoveToFirstChild(); while (c.Input.NodeType != XPathNodeType.Element) { if (!c.Input.MoveToNext()) { break; } } if (c.Input.NamespaceURI != XsltNamespace && c.Input.NodeType == XPathNodeType.Element) { // then it is simplified stylesheet. templates.Add(new XslTemplate(c)); } else { c.Input.MoveToFirstChild(); do { if (c.Input.NodeType != XPathNodeType.Element || c.Input.LocalName == "import" && c.Input.NamespaceURI == XsltNamespace) { continue; } Debug.EnterNavigator(c); HandleTopLevelElement(c); Debug.ExitNavigator(c); } while (c.Input.MoveToNext()); } c.Input.MoveToParent(); c.PopInputDocument(); }
internal void Compile (Compiler c) { c.PushStylesheet (this); templates = new XslTemplateTable (this); baseURI = c.Input.BaseURI; // 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) { if (c.Input.GetAttribute ("version", XsltNamespace) == String.Empty) throw new XsltCompileException ("Mandatory global attribute version is missing", null, c.Input); // 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 == String.Empty) throw new XsltCompileException ("Mandatory attribute version is missing", null, c.Input); extensionElementPrefixes = ParseMappedPrefixes (c.GetAttribute ("extension-element-prefixes"), c.Input); excludeResultPrefixes = ParseMappedPrefixes (c.GetAttribute ("exclude-result-prefixes"), c.Input); if (c.Input.MoveToFirstNamespace (XPathNamespaceScope.Local)) { do { if (c.Input.Value == XsltNamespace) continue; this.stylesheetNamespaces.Insert (0, new QName (c.Input.Name, c.Input.Value)); } while (c.Input.MoveToNextNamespace (XPathNamespaceScope.Local)); c.Input.MoveToParent (); } ProcessTopLevelElements (c); } foreach (XslGlobalVariable v in variables.Values) c.AddGlobalVariable (v); foreach (ArrayList al in keys.Values) for (int i = 0; i < al.Count; i++) c.AddKey ((XslKey) al[i]); c.PopStylesheet (); inProcessIncludes = null; }
internal void Compile(Compiler c) { c.PushStylesheet(this); templates = new XslTemplateTable(this); baseURI = c.Input.BaseURI; // 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) { if (c.Input.GetAttribute("version", XsltNamespace) == String.Empty) { throw new XsltCompileException("Mandatory global attribute version is missing", null, c.Input); } // 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 == String.Empty) { throw new XsltCompileException("Mandatory attribute version is missing", null, c.Input); } extensionElementPrefixes = ParseMappedPrefixes(c.GetAttribute("extension-element-prefixes"), c.Input); excludeResultPrefixes = ParseMappedPrefixes(c.GetAttribute("exclude-result-prefixes"), c.Input); if (c.Input.MoveToFirstNamespace(XPathNamespaceScope.Local)) { do { if (c.Input.Value == XsltNamespace) { continue; } this.stylesheetNamespaces.Insert(0, new QName(c.Input.Name, c.Input.Value)); } while (c.Input.MoveToNextNamespace(XPathNamespaceScope.Local)); c.Input.MoveToParent(); } ProcessTopLevelElements(c); } foreach (XslGlobalVariable v in variables.Values) { c.AddGlobalVariable(v); } foreach (ArrayList al in keys.Values) { for (int i = 0; i < al.Count; i++) { c.AddKey((XslKey)al[i]); } } c.PopStylesheet(); inProcessIncludes = null; }