Ejemplo n.º 1
0
 internal override void Compile(Compiler compiler) {
     CheckEmpty(compiler);
     if (! compiler.CanHaveApplyImports) {
         throw XsltException.Create(Res.Xslt_ApplyImports);                
     }
     this.mode = compiler.CurrentMode;
     this.stylesheet = compiler.CompiledStylesheet;
 }
Ejemplo n.º 2
0
        //
        // The World of Compile
        //
        internal void Compile(NavigatorInput input, XmlResolver xmlResolver)
        {
            Debug.Assert(input != null);
            Debug.Assert(xmlResolver != null);
            //            Debug.Assert(evidence    != null); -- default evidence is null now
            Debug.Assert(_input == null && _atoms == null);
            _xmlResolver = xmlResolver;

            PushInputDocument(input);
            _rootScope = _scopeManager.PushScope();
            _queryStore = new List<TheQuery>();

            try
            {
                this.rootStylesheet = new Stylesheet();
                PushStylesheet(this.rootStylesheet);

                Debug.Assert(_input != null && _atoms != null);

                try
                {
                    this.CreateRootAction();
                }
                catch (XsltCompileException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    throw new XsltCompileException(e, this.Input.BaseURI, this.Input.LineNumber, this.Input.LinePosition);
                }

                this.stylesheet.ProcessTemplates();
                _rootAction.PorcessAttributeSets(this.rootStylesheet);
                this.stylesheet.SortWhiteSpace();

                if (_globalNamespaceAliasTable != null)
                {
                    this.stylesheet.ReplaceNamespaceAlias(this);
                    _rootAction.ReplaceNamespaceAlias(this);
                }
            }
            finally
            {
                PopInputDocument();
            }

            Debug.Assert(_rootAction != null);
            Debug.Assert(this.stylesheet != null);
            Debug.Assert(_queryStore != null);
            Debug.Assert(_input == null && _atoms == null);
        }
Ejemplo n.º 3
0
        //
        // The World of Compile
        //
        internal void Compile(NavigatorInput input, XmlResolver xmlResolver, Evidence evidence) {
#if DISABLE_CAS_USE
            evidence = null;
#endif
            Debug.Assert(input != null);
            Debug.Assert(xmlResolver != null);
//            Debug.Assert(evidence    != null); -- default evidence is null now
            Debug.Assert(this.input == null && this.atoms == null);
            this.xmlResolver = xmlResolver;

            PushInputDocument(input);
            this.rootScope  = this.scopeManager.PushScope();
            this.queryStore = new List<TheQuery>();

            try {
                this.rootStylesheet = new Stylesheet();
                PushStylesheet(this.rootStylesheet);

                Debug.Assert(this.input != null && this.atoms != null);

                try {
                    this.CreateRootAction();
                }
                catch (XsltCompileException) {
                    throw;
                }
                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();
#if !DISABLE_XSLT_SCRIPT
                CompileScript(evidence);
#endif
                if (evidence != null) {
                    this.rootAction.permissions = SecurityManager.GetStandardSandbox(evidence);
                }

                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);
        }
Ejemplo n.º 4
0
 internal void PushTemplateLookup(XPathNodeIterator nodeSet, XmlQualifiedName mode, Stylesheet importsOf) {
     Debug.Assert(this.templateLookup != null);
     this.templateLookup.Initialize(mode, importsOf);
     PushActionFrame(this.templateLookup, nodeSet);
 }
Ejemplo n.º 5
0
        //
        // Construction
        //
        public Processor(
            XPathNavigator doc, XsltArgumentList args, XmlResolver resolver,
            Stylesheet stylesheet, List<TheQuery> queryStore, RootAction rootAction,
            IXsltDebugger debugger
        ) {
            this.stylesheet = stylesheet;
            this.queryStore = queryStore;
            this.rootAction = rootAction;
            this.queryList  = new Query[queryStore.Count]; {
                for(int i = 0; i < queryStore.Count; i ++) {
                    queryList[i] = Query.Clone(queryStore[i].CompiledQuery.QueryTree);
                }
            }

            this.xsm                 = new StateMachine();
            this.document            = doc;
            this.builder             = null;
            this.actionStack         = new HWStack(StackIncrement);
            this.output              = this.rootAction.Output;
            this.permissions         = this.rootAction.permissions;
            this.resolver            = resolver ?? XmlNullResolver.Singleton;
            this.args                = args     ?? new XsltArgumentList();
            this.debugger            = debugger;
            if (this.debugger != null) {
                this.debuggerStack = new HWStack(StackIncrement, /*limit:*/1000);
                templateLookup     = new TemplateLookupActionDbg();
            }

            // Clone the compile-time KeyList
            if (this.rootAction.KeyList != null) {
                this.keyList = new Key[this.rootAction.KeyList.Count];
                for (int i = 0; i < this.keyList.Length; i ++) {
                    this.keyList[i] = this.rootAction.KeyList[i].Clone();
                }
            }

            this.scriptExtensions = new Hashtable(this.stylesheet.ScriptObjectTypes.Count); {
                foreach(DictionaryEntry entry in this.stylesheet.ScriptObjectTypes) {
                    string namespaceUri = (string)entry.Key;
                    if (GetExtensionObject(namespaceUri) != null) {
                        throw XsltException.Create(Res.Xslt_ScriptDub, namespaceUri);
                    }
                    scriptExtensions.Add(namespaceUri, Activator.CreateInstance((Type)entry.Value,
                        BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, null, null, null));
                }
            }

            this.PushActionFrame(this.rootAction, /*nodeSet:*/null);
        }
 internal void Initialize(XmlQualifiedName mode, Stylesheet importsOf) {
     this.mode      = mode;
     this.importsOf = importsOf;
 }
Ejemplo n.º 7
0
 internal TemplateManager(Stylesheet stylesheet, XmlQualifiedName mode) {
     this.mode       = mode;
     this.stylesheet = stylesheet;
 }
 internal void Initialize(XmlQualifiedName mode, Stylesheet importsOf)
 {
     this.mode      = mode;
     this.importsOf = importsOf;
 }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
 public override bool PreserveWhitespace(XPathNavigator node)
 {
     node = node.Clone();
     node.MoveToParent();
     return(_processor !.Stylesheet.PreserveWhiteSpace(_processor, node));
 }
Ejemplo n.º 11
0
 internal TemplateManager(Stylesheet stylesheet, XmlQualifiedName mode)
 {
     _mode = mode;
     _stylesheet = stylesheet;
 }
Ejemplo n.º 12
0
 internal void PushTemplateLookup(XPathNodeIterator nodeSet, XmlQualifiedName mode, Stylesheet importsOf)
 {
     Debug.Assert(_templateLookup != null);
     _templateLookup.Initialize(mode, importsOf);
     PushActionFrame(_templateLookup, nodeSet);
 }
        //
        // Stylesheet management
        //

        internal void PushStylesheet(Stylesheet stylesheet)
        {
            _stylesheets ??= new Stack <Stylesheet>();
            _stylesheets.Push(stylesheet);
            this.stylesheet = stylesheet;
        }
 internal TemplateManager(Stylesheet stylesheet, XmlQualifiedName mode)
 {
     this.mode       = mode;
     this.stylesheet = stylesheet;
 }
Ejemplo n.º 15
0
        //
        // Stylesheet management
        //

        internal void PushStylesheet(Stylesheet stylesheet)
        {
            if (_stylesheets == null)
            {
                _stylesheets = new Stack();
            }
            Debug.Assert(_stylesheets != null);

            _stylesheets.Push(stylesheet);
            this.stylesheet = stylesheet;
        }
Ejemplo n.º 16
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);
            }
        }
Ejemplo n.º 17
0
 internal Stylesheet PopStylesheet()
 {
     Debug.Assert(this.stylesheet == _stylesheets.Peek());
     Stylesheet stylesheet = (Stylesheet)_stylesheets.Pop();
     this.stylesheet = (Stylesheet)_stylesheets.Peek();
     return stylesheet;
 }
Ejemplo n.º 18
0
 internal TemplateManager(Stylesheet stylesheet, XmlQualifiedName mode)
 {
     _mode       = mode;
     _stylesheet = stylesheet;
 }