private void CompileContent(Compiler compiler) { NavigatorInput input = compiler.Input; if (compiler.Recurse()) { do { Debug.Trace(input); switch(input.NodeType) { case XPathNodeType.Element: compiler.PushNamespaceScope(); string nspace = input.NamespaceURI; string name = input.LocalName; if (Keywords.Equals(nspace, input.Atoms.XsltNamespace) && Keywords.Equals(name, input.Atoms.WithParam)) { WithParamAction par = compiler.CreateWithParamAction(); CheckDuplicateParams(par.Name); AddAction(par); } else { throw XsltException.UnexpectedKeyword(compiler); } compiler.PopScope(); break; case XPathNodeType.Comment: case XPathNodeType.ProcessingInstruction: case XPathNodeType.Whitespace: case XPathNodeType.SignificantWhitespace: break; default: throw new XsltException(Res.Xslt_InvalidContents, Keywords.s_CallTemplate); } } while(compiler.Advance()); compiler.ToParent(); } }
public void CompileAttributes(Compiler compiler) { NavigatorInput input = compiler.Input; string element = input.LocalName; if (input.MoveToFirstAttribute()) { do { Debug.TraceAttribute(input); if (! Keywords.Equals(input.NamespaceURI, input.Atoms.Empty)) continue; try { if (CompileAttribute(compiler) == false) { throw XsltException.InvalidAttribute(element, input.LocalName); } }catch(Exception) { if (! compiler.ForwardCompatibility) { throw; } else { // In ForwardCompatibility mode we ignoreing all unknown or incorrect attributes // If it's mandatory attribute we'l notice it absents later. } } } while (input.MoveToNextAttribute()); input.ToParent(); } }
internal virtual void CompileSingle(Compiler compiler) { this.match = Compiler.RootQuery; this.matchKey = Compiler.RootQueryKey; this.priority = Compiler.RootPriority; CompileOnceTemplate(compiler); }
protected override void Compile (Compiler c) { if (c.Debugger != null) c.Debugger.DebugCompile (this.DebugInput); c.CheckExtraAttributes ("value-of", "select", "disable-output-escaping"); c.AssertAttribute ("select"); select = c.CompileExpression (c.GetAttribute ("select")); disableOutputEscaping = c.ParseYesNoAttribute ("disable-output-escaping", false); if (c.Input.MoveToFirstChild ()) { do { switch (c.Input.NodeType) { case XPathNodeType.Element: if (c.Input.NamespaceURI == XsltNamespace) goto case XPathNodeType.SignificantWhitespace; // otherwise element in external namespace -> ignore break; case XPathNodeType.Text: case XPathNodeType.SignificantWhitespace: throw new XsltCompileException ("XSLT value-of element cannot contain any child.", null, c.Input); } } while (c.Input.MoveToNext ()); } }
protected override void Compile (Compiler c) { if (c.Debugger != null) c.Debugger.DebugCompile (this.DebugInput); c.CheckExtraAttributes ("number", "level", "count", "from", "value", "format", "lang", "letter-value", "grouping-separator", "grouping-size"); switch (c.GetAttribute ("level")) { case "single": level = XslNumberingLevel.Single; break; case "multiple": level = XslNumberingLevel.Multiple; break; case "any": level = XslNumberingLevel.Any; break; case null: case "": default: level = XslNumberingLevel.Single; // single == default break; } count = c.CompilePattern (c.GetAttribute ("count"), c.Input); from = c.CompilePattern (c.GetAttribute ("from"), c.Input); value = c.CompileExpression (c.GetAttribute ("value")); format = c.ParseAvtAttribute ("format"); lang = c.ParseAvtAttribute ("lang"); letterValue = c.ParseAvtAttribute ("letter-value"); groupingSeparator = c.ParseAvtAttribute ("grouping-separator"); groupingSize = c.ParseAvtAttribute ("grouping-size"); }
protected override void Compile (Compiler c) { if (c.Debugger != null) c.Debugger.DebugCompile (this.DebugInput); prefix = c.Input.Prefix; string alias = c.CurrentStylesheet.GetActualPrefix (prefix); if (alias != prefix) { prefix = alias; nsUri = c.Input.GetNamespace (alias); } else nsUri = c.Input.NamespaceURI; this.localname = c.Input.LocalName; this.useAttributeSets = c.ParseQNameListAttribute ("use-attribute-sets", XsltNamespace); this.nsDecls = c.GetNamespacesToCopy (); if (nsDecls.Count == 0) nsDecls = null; this.isEmptyElement = c.Input.IsEmptyElement; if (c.Input.MoveToFirstAttribute ()) { attrs = new ArrayList (); do { if (c.Input.NamespaceURI == XsltNamespace) continue; //already handled attrs.Add (new XslLiteralAttribute (c)); } while (c.Input.MoveToNextAttribute()); c.Input.MoveToParent (); } if (!c.Input.MoveToFirstChild ()) return; children = c.CompileTemplateContent (); c.Input.MoveToParent (); }
internal override void Compile(Compiler compiler) { CompileAttributes(compiler); if (compiler.Recurse()) { CompileTemplate(compiler); compiler.ToParent(); } }
internal override void Compile(Compiler compiler) { CompileAttributes(compiler); if (compiler.Recurse()) { CompileConditions(compiler); compiler.ToParent(); } }
public XslTemplateContent (Compiler c, XPathNodeType parentType, bool xslForEach) : base (c) { this.parentType = parentType; this.xslForEach = xslForEach; Compile (c); }
internal override void Compile(Compiler compiler) { CheckEmpty(compiler); if (! compiler.CanHaveApplyImports) { throw new XsltException(Res.Xslt_ApplyImports); } this.mode = compiler.CurrentMode; this.stylesheet = compiler.CompiledStylesheet; }
internal static Avt CompileAvt(Compiler compiler, string avtText) { Debug.Assert(compiler != null); Debug.Assert(avtText != null); new ArrayList(); bool constant; ArrayList list = compiler.CompileAvt(avtText, out constant); return constant ? new Avt(avtText) : new Avt(list); }
internal override void Compile(Compiler compiler) { XPathNavigator nav = compiler.Input.Navigator.Clone(); string name = nav.Name; nav.MoveToParent(); string parent = nav.Name; if (compiler.Recurse()) { CompileSelectiveTemplate(compiler); compiler.ToParent(); } }
internal override void Compile(Compiler compiler) { Debug.Assert(!IsBuiltInAction); CompileAttributes(compiler); CompileContent(compiler); if (this.sort && this.selectKey == Compiler.InvalidQueryKey){ this.select = "child::node()"; this.selectKey = compiler.AddQuery(this.select); } }
protected override void Compile (Compiler c) { if (c.Debugger != null) c.Debugger.DebugCompile (c.Input); c.CheckExtraAttributes ("copy-of", "select"); c.AssertAttribute ("select"); select = c.CompileExpression (c.GetAttribute ("select")); }
internal void CompileStylesheetAttributes(Compiler compiler) { NavigatorInput input = compiler.Input; string element = input.LocalName; string badAttribute = null; string version = null; if (input.MoveToFirstAttribute()) { do { Debug.TraceAttribute(input); string nspace = input.NamespaceURI; string name = input.LocalName; if (! Keywords.Equals(nspace, input.Atoms.Empty)) continue; Debug.WriteLine("Attribute name: \"" + name + "\""); if (Keywords.Equals(name, input.Atoms.Version)) { version = input.Value; if (1 <= XmlConvert.ToXPathDouble(version)) { compiler.ForwardCompatibility = (version != Keywords.s_Version10); } else { // XmlConvert.ToXPathDouble(version) an be NaN! if (! compiler.ForwardCompatibility) { throw XsltException.InvalidAttrValue(Keywords.s_Version, version); } } Debug.WriteLine("Version found: \"" + version + "\""); } else if (Keywords.Equals(name, input.Atoms.ExtensionElementPrefixes)) { compiler.InsertExtensionNamespace(input.Value); } else if (Keywords.Equals(name, input.Atoms.ExcludeResultPrefixes)) { compiler.InsertExcludedNamespace(input.Value); } else if (Keywords.Equals(name, input.Atoms.Id)) { // Do nothing here. } else { // We can have version atribute later. For now remember this attribute and continue badAttribute = name; } } while( input.MoveToNextAttribute()); input.ToParent(); } if (version == null) { throw new XsltException(Res.Xslt_MissingAttribute, Keywords.s_Version); } if (badAttribute != null && ! compiler.ForwardCompatibility) { throw XsltException.InvalidAttribute(element, badAttribute); } }
public override void ReplaceNamespaceAlias(Compiler compiler){ if (this.namespaceUri != String.Empty) { // Do we need to check this for namespace? NamespaceInfo ResultURIInfo = compiler.FindNamespaceAlias(this.namespaceUri); if (ResultURIInfo != null) { this.namespaceUri = ResultURIInfo.nameSpace; if (ResultURIInfo.prefix != null) { this.name = ResultURIInfo.prefix; } } } }
internal override void Compile(Compiler compiler) { CompileAttributes(compiler); if (compiler.Recurse()) { CompileTemplate(compiler); compiler.ToParent(); } if (this.containedActions == null) this.empty = true; }
protected override void Compile (Compiler c) { if (c.Debugger != null) c.Debugger.DebugCompile (c.Input); c.CheckExtraAttributes ("fallback"); if (!c.Input.MoveToFirstChild ()) return; children = c.CompileTemplateContent (); c.Input.MoveToParent (); }
internal override void Compile(Compiler compiler) { CompileAttributes(compiler); CheckRequiredAttribute(compiler, this.select, Keywords.s_Select); compiler.CanHaveApplyImports = false; if (compiler.Recurse()) { CompileSortElements(compiler); CompileTemplate(compiler); compiler.ToParent(); } }
// It does not automatically invoke Compile() in .ctor() public XslCompiledElementBase (Compiler c) { IXmlLineInfo li = c.Input as IXmlLineInfo; if (li != null) { lineNumber = li.LineNumber; linePosition = li.LinePosition; } // store input only when the debugger is enabled if (c.Debugger != null) debugInput = c.Input.Clone (); }
internal override void Compile(Compiler compiler) { CompileAttributes(compiler); if (this.type != ConditionType.ConditionOtherwise) { CheckRequiredAttribute(compiler, this.testKey != Compiler.InvalidQueryKey, Keywords.s_Test); } if (compiler.Recurse()) { CompileTemplate(compiler); compiler.ToParent(); } }
internal override void Compile(Compiler compiler) { CompileAttributes(compiler); CheckRequiredAttribute(compiler, this.name, Keywords.s_Name); if (compiler.Recurse()) { CompileTemplate(compiler); compiler.ToParent(); if (this.select != null && this.containedActions != null) { throw new XsltException(Res.Xslt_VariableCntSel, this.nameStr, this.select); } } }
protected override void Compile (Compiler c) { if (c.Debugger != null) c.Debugger.DebugCompile (this.DebugInput); c.CheckExtraAttributes ("text", "disable-output-escaping"); this.text = c.Input.Value; if (c.Input.NodeType == XPathNodeType.Element) this.disableOutputEscaping = c.ParseYesNoAttribute ("disable-output-escaping", false); }
protected override void Compile (Compiler c) { if (c.Debugger != null) c.Debugger.DebugCompile (c.Input); c.CheckExtraAttributes ("comment"); if (c.Input.MoveToFirstChild ()) { value = c.CompileTemplateContent (XPathNodeType.Comment); c.Input.MoveToParent (); } }
protected override void Compile (Compiler c) { if (c.Debugger != null) c.Debugger.DebugCompile (c.Input); c.CheckExtraAttributes ("apply-templates", "select", "mode"); select = c.CompileExpression (c.GetAttribute ("select")); mode = c.ParseQNameAttribute ("mode"); ArrayList sorterList = null; if (c.Input.MoveToFirstChild ()) { do { switch (c.Input.NodeType) { case XPathNodeType.Comment: case XPathNodeType.ProcessingInstruction: case XPathNodeType.Whitespace: case XPathNodeType.SignificantWhitespace: continue; case XPathNodeType.Element: if (c.Input.NamespaceURI != XsltNamespace) throw new XsltCompileException ("Unexpected element", null, c.Input); // TODO: fwd compat switch (c.Input.LocalName) { case "with-param": if (withParams == null) withParams = new ArrayList (); withParams.Add (new XslVariableInformation (c)); break; case "sort": if (sorterList == null) sorterList = new ArrayList (); if (select == null) select = c.CompileExpression ("*"); sorterList.Add (new Sort (c)); //c.AddSort (select, new Sort (c)); break; default: throw new XsltCompileException ("Unexpected element", null, c.Input); // todo forwards compat } break; default: throw new XsltCompileException ("Unexpected node type " + c.Input.NodeType, null, c.Input); // todo forwards compat } } while (c.Input.MoveToNext ()); c.Input.MoveToParent (); } if (sorterList != null) sortEvaluator = new XslSortEvaluator (select, (Sort []) sorterList.ToArray (typeof (Sort))); }
internal override bool CompileAttribute(Compiler compiler) { string name = compiler.Input.LocalName; string value = compiler.Input.Value; if (Keywords.Equals(name, compiler.Atoms.Terminate)) { _Terminate = compiler.GetYesNo(value); Debug.WriteLine("Message terminate == \"" + _Terminate + "\""); } else { return false; } return true; }
internal override bool CompileAttribute(Compiler compiler) { string name = compiler.Input.LocalName; string value = compiler.Input.Value; if (Keywords.Equals(name, compiler.Atoms.Name)) { this.nameAvt = Avt.CompileAvt(compiler, value); Debug.WriteLine("name = \"" + value + "\""); } else { return false; } return true; }
internal override bool CompileAttribute(Compiler compiler) { string name = compiler.Input.LocalName; string value = compiler.Input.Value; if (Keywords.Equals(name, compiler.Atoms.UseAttributeSets)) { this.useAttributeSets = value; AddAction(compiler.CreateUseAttributeSetsAction()); Debug.WriteLine("UseAttributeSets = \"" + this.useAttributeSets + "\""); } else { return false; } return true; }
protected override void Compile (Compiler c) { if (c.Debugger != null) c.Debugger.DebugCompile (this.DebugInput); c.CheckExtraAttributes ("message", "terminate"); terminate = c.ParseYesNoAttribute ("terminate", false); if (!c.Input.MoveToFirstChild ()) return; children = c.CompileTemplateContent (); c.Input.MoveToParent (); }
internal override bool CompileAttribute(Compiler compiler) { string name = compiler.Input.LocalName; string value = compiler.Input.Value; if (Keywords.Equals(name, compiler.Atoms.DisableOutputEscaping)) { this.disableOutputEscaping = compiler.GetYesNo(value); } else { return false; } return true; }
public void Load(string url) { XmlTextReaderImpl tr = new XmlTextReaderImpl(url); Compile(Compiler.LoadDocument(tr).CreateNavigator(), XmlNullResolver.Singleton); }
public void Load(string url) { XmlTextReaderImpl tr = new XmlTextReaderImpl(url); Compile(Compiler.LoadDocument(tr).CreateNavigator(), CreateDefaultResolver()); }
public void Load([StringSyntax(StringSyntaxAttribute.Uri)] string url) { XmlTextReaderImpl tr = new XmlTextReaderImpl(url); Compile(Compiler.LoadDocument(tr).CreateNavigator(), CreateDefaultResolver()); }