public XslTemplate FindMatch(XPathNavigator node, XmlQualifiedName mode, XslTransformProcessor p) { XslTemplate ret; if (this [mode] != null) { ret = this [mode].FindMatch(node, p); if (ret != null) { return(ret); } } for (int i = parent.Imports.Count - 1; i >= 0; i--) { XslStylesheet s = (XslStylesheet)parent.Imports [i]; ret = s.Templates.FindMatch(node, mode, p); if (ret != null) { return(ret); } } return(null); }
public void PushStylesheet(XslStylesheet style) { if (this.currentStyle != null) { this.styleStack.Push(this.currentStyle); } this.currentStyle = style; }
public XslTransformProcessor (CompiledStylesheet style, object debugger) { this.XPathContext = new XsltCompiledContext (this); this.compiledStyle = style; this.style = style.Style; if (debugger != null) this.debugger = new XsltDebuggerWrapper (debugger); }
public void PushStylesheet(XslStylesheet style) { if (currentStyle != null) { styleStack.Push(currentStyle); } currentStyle = style; }
public void ApplyImports() { XslTemplate currentTemplate = (XslTemplate)currentTemplateStack.Peek(); if (currentTemplate == null) { throw new XsltException("Invalid context for apply-imports", null, CurrentNode); } XslTemplate t; for (int i = currentTemplate.Parent.Imports.Count - 1; i >= 0; i--) { XslStylesheet s = (XslStylesheet)currentTemplate.Parent.Imports [i]; t = s.Templates.FindMatch(CurrentNode, currentTemplate.Mode, this); if (t != null) { currentTemplateStack.Push(t); t.Evaluate(this); currentTemplateStack.Pop(); return; } } switch (CurrentNode.NodeType) { case XPathNodeType.Root: case XPathNodeType.Element: if (currentTemplate.Mode == QName.Empty) { t = XslDefaultNodeTemplate.Instance; } else { t = new XslDefaultNodeTemplate(currentTemplate.Mode); } break; case XPathNodeType.Attribute: case XPathNodeType.SignificantWhitespace: case XPathNodeType.Text: case XPathNodeType.Whitespace: t = XslDefaultTextTemplate.Instance; break; case XPathNodeType.Comment: case XPathNodeType.ProcessingInstruction: t = XslEmptyTemplate.Instance; break; default: t = XslEmptyTemplate.Instance; break; } currentTemplateStack.Push(t); t.Evaluate(this); currentTemplateStack.Pop(); }
private void HandleImport(Compiler c, string href) { c.PushInputDocument(href); XslStylesheet xslStylesheet = new XslStylesheet(); xslStylesheet.Compile(c); this.imports.Add(xslStylesheet); c.PopInputDocument(); }
private void HandleImport(Compiler c, string href) { c.PushInputDocument(href); XslStylesheet imported = new XslStylesheet(); imported.Compile(c); imports.Add(imported); c.PopInputDocument(); }
public XslTransformProcessor(CompiledStylesheet style, object debugger) { this.XPathContext = new XsltCompiledContext(this); this.compiledStyle = style; this.style = style.Style; if (debugger != null) { this.debugger = new XsltDebuggerWrapper(debugger); } }
public void PopStylesheet() { if (this.styleStack.Count == 0) { this.currentStyle = null; } else { this.currentStyle = (XslStylesheet)this.styleStack.Pop(); } }
public void PopStylesheet() { if (styleStack.Count == 0) { currentStyle = null; } else { currentStyle = (XslStylesheet)styleStack.Pop(); } }
public CompiledStylesheet(XslStylesheet style, Hashtable globalVariables, Hashtable attrSets, XmlNamespaceManager nsMgr, Hashtable keys, Hashtable outputs, Hashtable decimalFormats, MSXslScriptManager msScripts) { this.style = style; this.globalVariables = globalVariables; this.attrSets = attrSets; this.nsMgr = nsMgr; this.keys = keys; this.outputs = outputs; this.decimalFormats = decimalFormats; this.msScripts = msScripts; }
public CompiledStylesheet (XslStylesheet style, Hashtable globalVariables, Hashtable attrSets, XmlNamespaceManager nsMgr, Hashtable keys, Hashtable outputs, Hashtable decimalFormats, MSXslScriptManager msScripts) { this.style = style; this.globalVariables = globalVariables; this.attrSets = attrSets; this.nsMgr = nsMgr; this.keys = keys; this.outputs = outputs; this.decimalFormats = decimalFormats; this.msScripts = msScripts; }
public XslTemplate(Compiler c) { if (c == null) { return; // built in template } this.style = c.CurrentStylesheet; c.PushScope(); if (c.Input.Name == "template" && c.Input.NamespaceURI == Compiler.XsltNamespace && c.Input.MoveToAttribute("mode", String.Empty)) { c.Input.MoveToParent(); if (!c.Input.MoveToAttribute("match", String.Empty)) { throw new XsltCompileException("XSLT 'template' element must not have 'mode' attribute when it does not have 'match' attribute", null, c.Input); } c.Input.MoveToParent(); } if (c.Input.NamespaceURI != Compiler.XsltNamespace) { this.name = QName.Empty; this.match = c.CompilePattern("/", c.Input); this.mode = QName.Empty; } else { this.name = c.ParseQNameAttribute("name"); this.match = c.CompilePattern(c.GetAttribute("match"), c.Input); this.mode = c.ParseQNameAttribute("mode"); string pri = c.GetAttribute("priority"); if (pri != null) { try { this.priority = double.Parse(pri, CultureInfo.InvariantCulture); } catch (FormatException ex) { throw new XsltException("Invalid priority number format", ex, c.Input); } } } Parse(c); stackSize = c.PopScope().VariableHighTide; }
public CompiledStylesheet Compile(XPathNavigator nav, XmlResolver res, Evidence evidence) { this.xpathParser = new XPathParser(this); this.patternParser = new XsltPatternParser(this); this.res = res; if (res == null) { this.res = new XmlUrlResolver(); } this.evidence = evidence; // 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); } while (nav.NodeType != XPathNodeType.Element) { nav.MoveToNext(); } stylesheetVersion = nav.GetAttribute("version", (nav.NamespaceURI != XsltNamespace) ? XsltNamespace : String.Empty); outputs [""] = new XslOutput("", stylesheetVersion); PushInputDocument(nav); if (nav.MoveToFirstNamespace(XPathNamespaceScope.ExcludeXml)) { do { nsMgr.AddNamespace(nav.LocalName, nav.Value); }while (nav.MoveToNextNamespace(XPathNamespaceScope.ExcludeXml)); nav.MoveToParent(); } try { rootStyle = new XslStylesheet(); rootStyle.Compile(this); } catch (XsltCompileException) { throw; } catch (Exception x) { throw new XsltCompileException("XSLT compile error. " + x.Message, x, Input); } return(new CompiledStylesheet(rootStyle, globalVariables, attrSets, nsMgr, keys, outputs, decimalFormats, msScripts)); }
public void ApplyImports() { XslTemplate xslTemplate = (XslTemplate)this.currentTemplateStack.Peek(); if (xslTemplate == null) { throw new XsltException("Invalid context for apply-imports", null, this.CurrentNode); } XslTemplate xslTemplate2; for (int i = xslTemplate.Parent.Imports.Count - 1; i >= 0; i--) { XslStylesheet xslStylesheet = (XslStylesheet)xslTemplate.Parent.Imports[i]; xslTemplate2 = xslStylesheet.Templates.FindMatch(this.CurrentNode, xslTemplate.Mode, this); if (xslTemplate2 != null) { this.currentTemplateStack.Push(xslTemplate2); xslTemplate2.Evaluate(this); this.currentTemplateStack.Pop(); return; } } switch (this.CurrentNode.NodeType) { case XPathNodeType.Root: case XPathNodeType.Element: if (xslTemplate.Mode == XmlQualifiedName.Empty) { xslTemplate2 = XslDefaultNodeTemplate.Instance; } else { xslTemplate2 = new XslDefaultNodeTemplate(xslTemplate.Mode); } goto IL_131; case XPathNodeType.Attribute: case XPathNodeType.Text: case XPathNodeType.SignificantWhitespace: case XPathNodeType.Whitespace: xslTemplate2 = XslDefaultTextTemplate.Instance; goto IL_131; case XPathNodeType.ProcessingInstruction: case XPathNodeType.Comment: xslTemplate2 = XslEmptyTemplate.Instance; goto IL_131; } xslTemplate2 = XslEmptyTemplate.Instance; IL_131: this.currentTemplateStack.Push(xslTemplate2); xslTemplate2.Evaluate(this); this.currentTemplateStack.Pop(); }
public XslTemplate(Compiler c) { if (c == null) { return; } this.style = c.CurrentStylesheet; c.PushScope(); if (c.Input.Name == "template" && c.Input.NamespaceURI == "http://www.w3.org/1999/XSL/Transform" && c.Input.MoveToAttribute("mode", string.Empty)) { c.Input.MoveToParent(); if (!c.Input.MoveToAttribute("match", string.Empty)) { throw new XsltCompileException("XSLT 'template' element must not have 'mode' attribute when it does not have 'match' attribute", null, c.Input); } c.Input.MoveToParent(); } if (c.Input.NamespaceURI != "http://www.w3.org/1999/XSL/Transform") { this.name = XmlQualifiedName.Empty; this.match = c.CompilePattern("/", c.Input); this.mode = XmlQualifiedName.Empty; } else { this.name = c.ParseQNameAttribute("name"); this.match = c.CompilePattern(c.GetAttribute("match"), c.Input); this.mode = c.ParseQNameAttribute("mode"); string attribute = c.GetAttribute("priority"); if (attribute != null) { try { this.priority = double.Parse(attribute, CultureInfo.InvariantCulture); } catch (FormatException innerException) { throw new XsltException("Invalid priority number format", innerException, c.Input); } } } this.Parse(c); this.stackSize = c.PopScope().VariableHighTide; }
public CompiledStylesheet Compile(XPathNavigator nav, XmlResolver res, Evidence evidence) { this.xpathParser = new XPathParser(this); this.patternParser = new XsltPatternParser(this); this.res = res; if (res == null) { this.res = new XmlUrlResolver(); } this.evidence = evidence; 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); } while (nav.NodeType != XPathNodeType.Element) { nav.MoveToNext(); } this.stylesheetVersion = nav.GetAttribute("version", (!(nav.NamespaceURI != "http://www.w3.org/1999/XSL/Transform")) ? string.Empty : "http://www.w3.org/1999/XSL/Transform"); this.outputs[string.Empty] = new XslOutput(string.Empty, this.stylesheetVersion); this.PushInputDocument(nav); if (nav.MoveToFirstNamespace(XPathNamespaceScope.ExcludeXml)) { do { this.nsMgr.AddNamespace(nav.LocalName, nav.Value); }while (nav.MoveToNextNamespace(XPathNamespaceScope.ExcludeXml)); nav.MoveToParent(); } try { this.rootStyle = new XslStylesheet(); this.rootStyle.Compile(this); } catch (XsltCompileException) { throw; } catch (Exception ex) { throw new XsltCompileException("XSLT compile error. " + ex.Message, ex, this.Input); } return(new CompiledStylesheet(this.rootStyle, this.globalVariables, this.attrSets, this.nsMgr, this.keys, this.outputs, this.decimalFormats, this.msScripts)); }
public XslTemplate FindTemplate(XmlQualifiedName name) { XslTemplate xslTemplate = (XslTemplate)this.namedTemplates[name]; if (xslTemplate != null) { return(xslTemplate); } for (int i = this.parent.Imports.Count - 1; i >= 0; i--) { XslStylesheet xslStylesheet = (XslStylesheet)this.parent.Imports[i]; xslTemplate = xslStylesheet.Templates.FindTemplate(name); if (xslTemplate != null) { return(xslTemplate); } } return(null); }
private bool ComputeHasSpaceControls() { if (this.spaceControls.Count > 0 && this.HasStripSpace(this.spaceControls)) { return(true); } if (this.imports.Count == 0) { return(false); } for (int i = 0; i < this.imports.Count; i++) { XslStylesheet xslStylesheet = (XslStylesheet)this.imports[i]; if (xslStylesheet.spaceControls.Count > 0 && this.HasStripSpace(xslStylesheet.spaceControls)) { return(true); } } return(false); }
public XslTemplate FindMatch(XPathNavigator node, XmlQualifiedName mode, XslTransformProcessor p) { if (this[mode] != null) { XslTemplate xslTemplate = this[mode].FindMatch(node, p); if (xslTemplate != null) { return(xslTemplate); } } for (int i = this.parent.Imports.Count - 1; i >= 0; i--) { XslStylesheet xslStylesheet = (XslStylesheet)this.parent.Imports[i]; XslTemplate xslTemplate = xslStylesheet.Templates.FindMatch(node, mode, p); if (xslTemplate != null) { return(xslTemplate); } } return(null); }
public XslTemplate FindTemplate(XmlQualifiedName name) { XslTemplate ret = (XslTemplate)namedTemplates [name]; if (ret != null) { return(ret); } for (int i = parent.Imports.Count - 1; i >= 0; i--) { XslStylesheet s = (XslStylesheet)parent.Imports [i]; ret = s.Templates.FindTemplate(name); if (ret != null) { return(ret); } } return(null); }
private bool ComputeHasSpaceControls() { if (this.spaceControls.Count > 0 && HasStripSpace(spaceControls)) { return(true); } if (imports.Count == 0) { return(false); } for (int i = 0; i < imports.Count; i++) { XslStylesheet s = (XslStylesheet)imports [i]; if (s.spaceControls.Count > 0 && HasStripSpace(s.spaceControls)) { return(true); } } return(false); }
private void HandleImport (Compiler c, string href) { c.PushInputDocument (href); XslStylesheet imported = new XslStylesheet (); imported.Compile (c); imports.Add (imported); c.PopInputDocument (); }
public XslTemplate (Compiler c) { if (c == null) return; // built in template this.style = c.CurrentStylesheet; c.PushScope (); if (c.Input.Name == "template" && c.Input.NamespaceURI == Compiler.XsltNamespace && c.Input.MoveToAttribute ("mode", String.Empty)) { c.Input.MoveToParent (); if (!c.Input.MoveToAttribute ("match", String.Empty)) throw new XsltCompileException ("XSLT 'template' element must not have 'mode' attribute when it does not have 'match' attribute", null, c.Input); c.Input.MoveToParent (); } if (c.Input.NamespaceURI != Compiler.XsltNamespace) { this.name = QName.Empty; this.match = c.CompilePattern ("/", c.Input); this.mode = QName.Empty; } else { this.name = c.ParseQNameAttribute ("name"); this.match = c.CompilePattern (c.GetAttribute ("match"), c.Input); this.mode = c.ParseQNameAttribute ("mode"); string pri = c.GetAttribute ("priority"); if (pri != null) { try { this.priority = double.Parse (pri, CultureInfo.InvariantCulture); } catch (FormatException ex) { throw new XsltException ("Invalid priority number format", ex, c.Input); } } } Parse (c); stackSize = c.PopScope ().VariableHighTide; }
public CompiledStylesheet Compile (XPathNavigator nav, XmlResolver res, Evidence evidence) { this.xpathParser = new XPathParser (this); this.patternParser = new XsltPatternParser (this); this.res = res; if (res == null) this.res = new XmlUrlResolver (); this.evidence = evidence; // 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); while (nav.NodeType != XPathNodeType.Element) nav.MoveToNext(); stylesheetVersion = nav.GetAttribute ("version", (nav.NamespaceURI != XsltNamespace) ? XsltNamespace : String.Empty); outputs [""] = new XslOutput ("", stylesheetVersion); PushInputDocument (nav); if (nav.MoveToFirstNamespace (XPathNamespaceScope.ExcludeXml)) { do { nsMgr.AddNamespace (nav.LocalName, nav.Value); } while (nav.MoveToNextNamespace (XPathNamespaceScope.ExcludeXml)); nav.MoveToParent (); } try { rootStyle = new XslStylesheet (); rootStyle.Compile (this); } catch (XsltCompileException) { throw; } catch (Exception x) { throw new XsltCompileException ("XSLT compile error. " + x.Message, x, Input); } return new CompiledStylesheet (rootStyle, globalVariables, attrSets, nsMgr, keys, outputs, decimalFormats, msScripts); }
public XslTemplateTable(XslStylesheet parent) { this.parent = parent; }
public void PushStylesheet (XslStylesheet style) { if (currentStyle != null) styleStack.Push (currentStyle); currentStyle = style; }
public void PopStylesheet () { if (styleStack.Count == 0) currentStyle = null; else currentStyle = (XslStylesheet)styleStack.Pop (); }
public XslTemplateTable (XslStylesheet parent) { this.parent = parent; }