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; }
public void PorcessAttributeSets(Stylesheet rootStylesheet) { MirgeAttributeSets(rootStylesheet); // As we mentioned we need to invert all lists. foreach (AttributeSetAction attSet in this.attributeSetTable.Values) { if (attSet.containedActions != null) { attSet.containedActions.Reverse(); } } // ensures there are no cycles in the attribute-sets use dfs marking method CheckAttributeSets_RecurceInList(new Hashtable(), this.attributeSetTable.Keys); }
internal Stylesheet PopStylesheet() { Debug.Assert(this.stylesheet == this.stylesheets.Peek()); Stylesheet stylesheet = (Stylesheet) this.stylesheets.Pop(); this.stylesheet = (Stylesheet) this.stylesheets.Peek(); return stylesheet; }
// // Stylesheet management // internal void PushStylesheet(Stylesheet stylesheet) { if (this.stylesheets == null) { this.stylesheets = new Stack(); } Debug.Assert(this.stylesheets != null); this.stylesheets.Push(stylesheet); this.stylesheet = stylesheet; }
// // The World of Compile // internal void Compile(NavigatorInput input, XmlResolver xmlResolver) { Debug.Assert(this.input == null && this.atoms == null); this.xmlResolver = xmlResolver == null ? new XmlUrlResolver() : xmlResolver; PushInputDocument(input, input.BaseURI); this.rootScope = this.scopeManager.PushScope(); this.queryStore = new ArrayList(); AddSpecialQueries(); try { this.rootStylesheet = new Stylesheet(); PushStylesheet(this.rootStylesheet); Debug.Assert(this.input != null && this.atoms != null); try { this.CreateRootAction(); } catch(Exception e) { throw new XsltCompileException(e, this.Input.BaseURI, this.Input.LineNumber, this.Input.LinePosition); } this.stylesheet.ProcessTemplates(); this.rootAction.PorcessAttributeSets(this.rootStylesheet); this.stylesheet.SortWhiteSpace(); CompileScript(); this.rootAction.SortVariables(); if (this.globalNamespaceAliasTable != null ) { this.stylesheet.ReplaceNamespaceAlias(this); this.rootAction.ReplaceNamespaceAlias(this); } } finally { PopInputDocument(); } Debug.Assert(this.rootAction != null); Debug.Assert(this.stylesheet != null); Debug.Assert(this.queryStore != null); Debug.Assert(this.input == null && this.atoms == null); }
internal void PushTemplateLookup(XPathNodeIterator nodeSet, XmlQualifiedName mode, Stylesheet importsOf) { Debug.Assert(this.templateLookup != null); this.templateLookup.Initialize(mode, importsOf); PushActionFrame(this.templateLookup, nodeSet); }
internal void LoadCompiledStylesheet(out Stylesheet compiledStylesheet, out XPathExpression[] querylist, out ArrayList queryStore, out RootAction rootAction, XPathNavigator input) { // // Extract the state atomically // if (_CompiledStylesheet == null || _QueryStore == null || _RootAction == null) { throw new XsltException(Res.Xslt_NoStylesheetLoaded); } compiledStylesheet = _CompiledStylesheet; queryStore = _QueryStore; rootAction = _RootAction; int queryCount = _QueryStore.Count; querylist = new XPathExpression[queryCount]; { bool canClone = input is DocumentXPathNavigator || input is XPathDocumentNavigator; for(int i = 0; i < queryCount; i ++) { XPathExpression query = ((TheQuery)_QueryStore[i]).CompiledQuery; querylist[i] = canClone ? query.Clone() : input.Compile(query.Expression); } } }
// // Implementation // private void StoreCompiledStylesheet(Stylesheet compiledStylesheet, ArrayList queryStore, RootAction rootAction) { Debug.Assert(queryStore != null); Debug.Assert(compiledStylesheet != null); Debug.Assert(rootAction != null); // // Set the new state atomically // // lock(this) { _CompiledStylesheet = compiledStylesheet; _QueryStore = queryStore; _RootAction = rootAction; // } }
internal void Initialize(XmlQualifiedName mode, Stylesheet importsOf) { this.mode = mode; this.importsOf = importsOf; }
private void MirgeAttributeSets(Stylesheet stylesheet) { // mirge stylesheet.AttributeSetTable to this.AttributeSetTable if (stylesheet.AttributeSetTable != null) { foreach (AttributeSetAction srcAttSet in stylesheet.AttributeSetTable.Values) { ArrayList srcAttList = srcAttSet.containedActions; AttributeSetAction dstAttSet = (AttributeSetAction) this.attributeSetTable[srcAttSet.Name]; if (dstAttSet == null) { dstAttSet = new AttributeSetAction(); { dstAttSet.name = srcAttSet.Name; dstAttSet.containedActions = new ArrayList(); } this.attributeSetTable[srcAttSet.Name] = dstAttSet; } ArrayList dstAttList = dstAttSet.containedActions; // We adding attributes in reverse order for purpuse. In the mirged list most importent attset shoud go last one // so we'll need to invert dstAttList finaly. if (srcAttList != null) { for(int src = srcAttList.Count - 1; 0 <= src; src --) { // We can ignore duplicate attibutes here. dstAttList.Add(srcAttList[src]); } } } } foreach (Stylesheet importedStylesheet in stylesheet.Imports) { MirgeAttributeSets(importedStylesheet); } }
internal TemplateManager(Stylesheet stylesheet, XmlQualifiedName mode) { this.mode = mode; this.stylesheet = stylesheet; }