Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 internal Stylesheet PopStylesheet() {
     Debug.Assert(this.stylesheet == this.stylesheets.Peek());
     Stylesheet stylesheet = (Stylesheet) this.stylesheets.Pop();
     this.stylesheet = (Stylesheet) this.stylesheets.Peek();
     return stylesheet;
 }
Exemplo n.º 4
0
        //
        // 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;
        }
Exemplo n.º 5
0
        //
        // 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);
        }
Exemplo n.º 6
0
 internal void PushTemplateLookup(XPathNodeIterator nodeSet, XmlQualifiedName mode, Stylesheet importsOf) {
     Debug.Assert(this.templateLookup != null);
     this.templateLookup.Initialize(mode, importsOf);
     PushActionFrame(this.templateLookup, nodeSet);
 }
Exemplo n.º 7
0
        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);
                }
            }
        }
Exemplo n.º 8
0
        //
        // 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;
            //    }
        }
Exemplo n.º 9
0
 internal void Initialize(XmlQualifiedName mode, Stylesheet importsOf) {
     this.mode      = mode;
     this.importsOf = importsOf;
 }
Exemplo n.º 10
0
        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);
            }
        }
Exemplo n.º 11
0
 internal void Initialize(XmlQualifiedName mode, Stylesheet importsOf)
 {
     this.mode      = mode;
     this.importsOf = importsOf;
 }
Exemplo n.º 12
0
 internal TemplateManager(Stylesheet stylesheet, XmlQualifiedName mode) {
     this.mode       = mode;
     this.stylesheet = stylesheet;
 }