Esempio n. 1
0
 public NamespaceEvent(NavigatorInput input)
 {
     Debug.Assert(input != null);
     Debug.Assert(input.NodeType == XPathNodeType.Namespace);
     _namespaceUri = input.Value;
     _name = input.LocalName;
 }
Esempio n. 2
0
        internal string GetSingleAttribute(string attributeAtom)
        {
            NavigatorInput input   = Input !;
            string         element = input.LocalName;
            string?        value   = null;

            if (input.MoveToFirstAttribute())
            {
                do
                {
                    string nspace = input.NamespaceURI;
                    string name   = input.LocalName;

                    if (nspace.Length != 0)
                    {
                        continue;
                    }

                    if (Ref.Equal(name, attributeAtom))
                    {
                        value = input.Value;
                    }
                    else
                    {
                        if (!this.ForwardCompatibility)
                        {
                            throw XsltException.Create(SR.Xslt_InvalidAttribute, name, element);
                        }
                    }
                }while (input.MoveToNextAttribute());
                input.ToParent();
            }

            if (value == null)
            {
                throw XsltException.Create(SR.Xslt_MissingAttribute, attributeAtom);
            }
            return(value);
        }
Esempio n. 3
0
        internal Stylesheet CompileImport(Compiler compiler, Uri uri, int id)
        {
            NavigatorInput input = compiler.ResolveDocument(uri);

            compiler.PushInputDocument(input);

            try {
                compiler.PushStylesheet(new Stylesheet());
                compiler.Stylesheetid = id;
                CompileDocument(compiler, /*inInclude*/ false);
            }
            catch (XsltCompileException) {
                throw;
            }
            catch (Exception e) {
                throw new XsltCompileException(e, input.BaseURI, input.LineNumber, input.LinePosition);
            }
            finally {
                compiler.PopInputDocument();
            }
            return(compiler.PopStylesheet());
        }
Esempio n. 4
0
        internal void CompileSingleTemplate(Compiler compiler)
        {
            NavigatorInput input = compiler.Input;

            //
            // find mandatory version attribute and launch compilation of single template
            //

            string?version = null;

            if (input.MoveToFirstAttribute())
            {
                do
                {
                    string nspace = input.NamespaceURI;
                    string name   = input.LocalName;

                    if (Ref.Equal(nspace, input.Atoms.UriXsl) &&
                        Ref.Equal(name, input.Atoms.Version))
                    {
                        version = input.Value;
                    }
                }while (input.MoveToNextAttribute());
                input.ToParent();
            }

            if (version == null)
            {
                if (Ref.Equal(input.LocalName, input.Atoms.Stylesheet) &&
                    input.NamespaceURI == XmlReservedNs.NsWdXsl)
                {
                    throw XsltException.Create(SR.Xslt_WdXslNamespace);
                }
                throw XsltException.Create(SR.Xslt_WrongStylesheetElement);
            }

            compiler.AddTemplate(compiler.CreateSingleTemplateAction());
        }
Esempio n. 5
0
        private void AnalyzePriority(Compiler compiler)
        {
            NavigatorInput input = compiler.Input;

            if (!Double.IsNaN(this.priority) || this.matchKey == Compiler.InvalidQueryKey)
            {
                return;
            }
            // Split Unions:
            TheQuery          theQuery = (TheQuery)compiler.QueryStore[this.MatchKey];
            CompiledXpathExpr expr     = (CompiledXpathExpr)theQuery.CompiledQuery;
            Query             query    = expr.QueryTree;
            UnionExpr         union;

            while ((union = query as UnionExpr) != null)
            {
                Debug.Assert(!(union.qy2 is UnionExpr), "only qy1 can be union");
                TemplateAction copy = this.CloneWithoutName();
                compiler.QueryStore.Add(new TheQuery(
                                            new CompiledXpathExpr(union.qy2, expr.Expression, false),
                                            theQuery._ScopeManager
                                            ));
                copy.matchKey = compiler.QueryStore.Count - 1;
                copy.priority = union.qy2.XsltDefaultPriority;
                compiler.AddTemplate(copy);

                query = union.qy1;
            }
            if (expr.QueryTree != query)
            {
                // query was splitted and we need create new TheQuery for this template
                compiler.QueryStore[this.MatchKey] = new TheQuery(
                    new CompiledXpathExpr(query, expr.Expression, false),
                    theQuery._ScopeManager
                    );
            }
            this.priority = query.XsltDefaultPriority;
        }
Esempio n. 6
0
        public void CompileAttributes(Compiler compiler)
        {
            NavigatorInput input   = compiler.Input;
            string         element = input.LocalName;

            if (input.MoveToFirstAttribute())
            {
                do
                {
                    if (input.NamespaceURI.Length != 0)
                    {
                        continue;
                    }

                    try
                    {
                        if (CompileAttribute(compiler) == false)
                        {
                            throw XsltException.Create(SR.Xslt_InvalidAttribute, input.LocalName, element);
                        }
                    }
                    catch
                    {
                        if (!compiler.ForwardCompatibility)
                        {
                            throw;
                        }
                        else
                        {
                            // In ForwardCompatibility mode we ignoreing all unknown or incorrect attributes
                            // If it's mandatory attribute we'll notice it absence later.
                        }
                    }
                }while (input.MoveToNextAttribute());
                input.ToParent();
            }
        }
Esempio n. 7
0
        internal void PopInputDocument()
        {
            Debug.Assert(_input != null);
            Debug.Assert(_input.Atoms == _atoms);

            NavigatorInput lastInput = _input;

            _input         = lastInput.Next;
            lastInput.Next = null;

            if (_input != null)
            {
                _atoms        = _input.Atoms;
                _scopeManager = _input.InputScopeManager;
            }
            else
            {
                _atoms        = null;
                _scopeManager = null;
            }

            RemoveDocumentURI(lastInput.Href);
            lastInput.Close();
        }
Esempio n. 8
0
        internal void PopInputDocument()
        {
            Debug.Assert(this.input != null);
            Debug.Assert(this.input.Atoms == this.atoms);

            NavigatorInput lastInput = this.input;

            this.input     = lastInput.Next;
            lastInput.Next = null;

            if (this.input != null)
            {
                this.atoms        = this.input.Atoms;
                this.scopeManager = this.input.InputScopeManager;
            }
            else
            {
                this.atoms        = null;
                this.scopeManager = null;
            }

            RemoveDocumentURI(lastInput.Href);
            lastInput.Close();
        }
Esempio n. 9
0
        internal void PopInputDocument()
        {
            Debug.Assert(_input != null);
            Debug.Assert(_input.Atoms == _atoms);

            NavigatorInput lastInput = _input;

            _input = lastInput.Next;
            lastInput.Next = null;

            if (_input != null)
            {
                _atoms = _input.Atoms;
                _scopeManager = _input.InputScopeManager;
            }
            else
            {
                _atoms = null;
                _scopeManager = null;
            }

            RemoveDocumentURI(lastInput.Href);
            lastInput.Close();
        }
Esempio n. 10
0
        internal void PushInputDocument(NavigatorInput newInput)
        {
            Debug.Assert(newInput != null);
            string inputUri = newInput.Href;

            AddDocumentURI(inputUri);

            newInput.Next = _input;
            _input = newInput;
            _atoms = _input.Atoms;
            _scopeManager = _input.InputScopeManager;
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        private void AddScript(Compiler compiler)
        {
            NavigatorInput input = compiler.Input;

            ScriptingLanguage lang = ScriptingLanguage.JScript;
            string?           implementsNamespace = null;

            if (input.MoveToFirstAttribute())
            {
                do
                {
                    if (input.LocalName == input.Atoms.Language)
                    {
                        string langName = input.Value;
                        if (
                            string.Equals(langName, "jscript", StringComparison.OrdinalIgnoreCase) ||
                            string.Equals(langName, "javascript", StringComparison.OrdinalIgnoreCase)
                            )
                        {
                            lang = ScriptingLanguage.JScript;
                        }
                        else if (
                            string.Equals(langName, "c#", StringComparison.OrdinalIgnoreCase) ||
                            string.Equals(langName, "csharp", StringComparison.OrdinalIgnoreCase)
                            )
                        {
                            lang = ScriptingLanguage.CSharp;
                        }
                        else if (
                            string.Equals(langName, "vb", StringComparison.OrdinalIgnoreCase) ||
                            string.Equals(langName, "visualbasic", StringComparison.OrdinalIgnoreCase)
                            )
                        {
                            lang = ScriptingLanguage.VisualBasic;
                        }
                        else
                        {
                            throw XsltException.Create(SR.Xslt_ScriptInvalidLanguage, langName);
                        }
                    }
                    else if (input.LocalName == input.Atoms.ImplementsPrefix)
                    {
                        if (!PrefixQName.ValidatePrefix(input.Value))
                        {
                            throw XsltException.Create(SR.Xslt_InvalidAttrValue, input.LocalName, input.Value);
                        }
                        implementsNamespace = compiler.ResolveXmlNamespace(input.Value);
                    }
                }while (input.MoveToNextAttribute());
                input.ToParent();
            }
            if (implementsNamespace == null)
            {
                throw XsltException.Create(SR.Xslt_MissingAttribute, input.Atoms.ImplementsPrefix);
            }
            if (!input.Recurse() || input.NodeType != XPathNodeType.Text)
            {
                throw XsltException.Create(SR.Xslt_ScriptEmpty);
            }
            compiler.AddScript(input.Value, lang, implementsNamespace, input.BaseURI, input.LineNumber);
            input.ToParent();
        }
Esempio n. 13
0
        private void CompileInstruction(Compiler compiler)
        {
            NavigatorInput input  = compiler.Input;
            CompiledAction?action = null;

            Debug.Assert(Ref.Equal(input.NamespaceURI, input.Atoms.UriXsl));

            string name = input.LocalName;

            if (Ref.Equal(name, input.Atoms.ApplyImports))
            {
                action = compiler.CreateApplyImportsAction();
            }
            else if (Ref.Equal(name, input.Atoms.ApplyTemplates))
            {
                action = compiler.CreateApplyTemplatesAction();
            }
            else if (Ref.Equal(name, input.Atoms.Attribute))
            {
                action = compiler.CreateAttributeAction();
            }
            else if (Ref.Equal(name, input.Atoms.CallTemplate))
            {
                action = compiler.CreateCallTemplateAction();
            }
            else if (Ref.Equal(name, input.Atoms.Choose))
            {
                action = compiler.CreateChooseAction();
            }
            else if (Ref.Equal(name, input.Atoms.Comment))
            {
                action = compiler.CreateCommentAction();
            }
            else if (Ref.Equal(name, input.Atoms.Copy))
            {
                action = compiler.CreateCopyAction();
            }
            else if (Ref.Equal(name, input.Atoms.CopyOf))
            {
                action = compiler.CreateCopyOfAction();
            }
            else if (Ref.Equal(name, input.Atoms.Element))
            {
                action = compiler.CreateElementAction();
            }
            else if (Ref.Equal(name, input.Atoms.Fallback))
            {
                return;
            }
            else if (Ref.Equal(name, input.Atoms.ForEach))
            {
                action = compiler.CreateForEachAction();
            }
            else if (Ref.Equal(name, input.Atoms.If))
            {
                action = compiler.CreateIfAction(IfAction.ConditionType.ConditionIf);
            }
            else if (Ref.Equal(name, input.Atoms.Message))
            {
                action = compiler.CreateMessageAction();
            }
            else if (Ref.Equal(name, input.Atoms.Number))
            {
                action = compiler.CreateNumberAction();
            }
            else if (Ref.Equal(name, input.Atoms.ProcessingInstruction))
            {
                action = compiler.CreateProcessingInstructionAction();
            }
            else if (Ref.Equal(name, input.Atoms.Text))
            {
                action = compiler.CreateTextAction();
            }
            else if (Ref.Equal(name, input.Atoms.ValueOf))
            {
                action = compiler.CreateValueOfAction();
            }
            else if (Ref.Equal(name, input.Atoms.Variable))
            {
                action = compiler.CreateVariableAction(VariableType.LocalVariable);
            }
            else
            {
                if (compiler.ForwardCompatibility)
                {
                    action = compiler.CreateNewInstructionAction();
                }
                else
                {
                    throw compiler.UnexpectedKeyword();
                }
            }

            Debug.Assert(action != null);

            AddAction(action);
        }
Esempio n. 14
0
        // SxS: This method does not take any resource name and does not expose any resources to the caller.
        // It's OK to suppress the SxS warning.
        protected void CompileTopLevelElements(Compiler compiler)
        {
            // Navigator positioned at parent root, need to move to child and then back
            if (compiler.Recurse() == false)
            {
                return;
            }

            NavigatorInput input           = compiler.Input;
            bool           notFirstElement = false;

            do
            {
                switch (input.NodeType)
                {
                case XPathNodeType.Element:
                    string name   = input.LocalName;
                    string nspace = input.NamespaceURI;

                    if (Ref.Equal(nspace, input.Atoms.UriXsl))
                    {
                        if (Ref.Equal(name, input.Atoms.Import))
                        {
                            if (notFirstElement)
                            {
                                throw XsltException.Create(SR.Xslt_NotFirstImport);
                            }
                            // We should compile imports in reverse order after all toplevel elements.
                            // remember it now and return to it in CompileImpoorts();
                            Uri    uri      = compiler.ResolveUri(compiler.GetSingleAttribute(compiler.Input.Atoms.Href));
                            string resolved = uri.ToString();
                            if (compiler.IsCircularReference(resolved))
                            {
                                throw XsltException.Create(SR.Xslt_CircularInclude, resolved);
                            }
                            compiler.CompiledStylesheet !.Imports.Add(uri);
                            CheckEmpty(compiler);
                        }
                        else if (Ref.Equal(name, input.Atoms.Include))
                        {
                            notFirstElement = true;
                            CompileInclude(compiler);
                        }
                        else
                        {
                            notFirstElement = true;
                            compiler.PushNamespaceScope();
                            if (Ref.Equal(name, input.Atoms.StripSpace))
                            {
                                CompileSpace(compiler, false);
                            }
                            else if (Ref.Equal(name, input.Atoms.PreserveSpace))
                            {
                                CompileSpace(compiler, true);
                            }
                            else if (Ref.Equal(name, input.Atoms.Output))
                            {
                                CompileOutput(compiler);
                            }
                            else if (Ref.Equal(name, input.Atoms.Key))
                            {
                                CompileKey(compiler);
                            }
                            else if (Ref.Equal(name, input.Atoms.DecimalFormat))
                            {
                                CompileDecimalFormat(compiler);
                            }
                            else if (Ref.Equal(name, input.Atoms.NamespaceAlias))
                            {
                                CompileNamespaceAlias(compiler);
                            }
                            else if (Ref.Equal(name, input.Atoms.AttributeSet))
                            {
                                compiler.AddAttributeSet(compiler.CreateAttributeSetAction());
                            }
                            else if (Ref.Equal(name, input.Atoms.Variable))
                            {
                                VariableAction?action = compiler.CreateVariableAction(VariableType.GlobalVariable);
                                if (action != null)
                                {
                                    AddAction(action);
                                }
                            }
                            else if (Ref.Equal(name, input.Atoms.Param))
                            {
                                VariableAction?action = compiler.CreateVariableAction(VariableType.GlobalParameter);
                                if (action != null)
                                {
                                    AddAction(action);
                                }
                            }
                            else if (Ref.Equal(name, input.Atoms.Template))
                            {
                                compiler.AddTemplate(compiler.CreateTemplateAction());
                            }
                            else
                            {
                                if (!compiler.ForwardCompatibility)
                                {
                                    throw compiler.UnexpectedKeyword();
                                }
                            }
                            compiler.PopScope();
                        }
                    }
                    else if (nspace == input.Atoms.UrnMsxsl && name == input.Atoms.Script)
                    {
                        AddScript(compiler);
                    }
                    else
                    {
                        if (nspace.Length == 0)
                        {
                            throw XsltException.Create(SR.Xslt_NullNsAtTopLevel, input.Name);
                        }
                        // Ignoring non-recognized namespace per XSLT spec 2.2
                    }
                    break;

                case XPathNodeType.ProcessingInstruction:
                case XPathNodeType.Comment:
                case XPathNodeType.Whitespace:
                case XPathNodeType.SignificantWhitespace:
                    break;

                default:
                    throw XsltException.Create(SR.Xslt_InvalidContents, "stylesheet");
                }
            }while (compiler.Advance());

            compiler.ToParent();
        }
Esempio n. 15
0
        internal void CompileStylesheetAttributes(Compiler compiler)
        {
            NavigatorInput input        = compiler.Input;
            string         element      = input.LocalName;
            string?        badAttribute = null;
            string?        version      = null;

            if (input.MoveToFirstAttribute())
            {
                do
                {
                    string nspace = input.NamespaceURI;
                    string name   = input.LocalName;

                    if (nspace.Length != 0)
                    {
                        continue;
                    }

                    if (Ref.Equal(name, input.Atoms.Version))
                    {
                        version = input.Value;
                        if (1 <= XmlConvert.ToXPathDouble(version))
                        {
                            compiler.ForwardCompatibility = (version != "1.0");
                        }
                        else
                        {
                            // XmlConvert.ToXPathDouble(version) an be NaN!
                            if (!compiler.ForwardCompatibility)
                            {
                                throw XsltException.Create(SR.Xslt_InvalidAttrValue, "version", version);
                            }
                        }
                    }
                    else if (Ref.Equal(name, input.Atoms.ExtensionElementPrefixes))
                    {
                        compiler.InsertExtensionNamespace(input.Value);
                    }
                    else if (Ref.Equal(name, input.Atoms.ExcludeResultPrefixes))
                    {
                        compiler.InsertExcludedNamespace(input.Value);
                    }
                    else if (Ref.Equal(name, input.Atoms.Id))
                    {
                        // Do nothing here.
                    }
                    else
                    {
                        // We can have version attribute later. For now remember this attribute and continue
                        badAttribute = name;
                    }
                }while (input.MoveToNextAttribute());
                input.ToParent();
            }

            if (version == null)
            {
                throw XsltException.Create(SR.Xslt_MissingAttribute, "version");
            }

            if (badAttribute != null && !compiler.ForwardCompatibility)
            {
                throw XsltException.Create(SR.Xslt_InvalidAttribute, badAttribute, element);
            }
        }
Esempio n. 16
0
        protected void CompileDecimalFormat(Compiler compiler)
        {
            NumberFormatInfo info   = new NumberFormatInfo();
            DecimalFormat    format = new DecimalFormat(info, '#', '0', ';');
            XmlQualifiedName?Name   = null;
            NavigatorInput   input  = compiler.Input;

            if (input.MoveToFirstAttribute())
            {
                do
                {
                    if (input.Prefix.Length != 0)
                    {
                        continue;
                    }

                    string name  = input.LocalName;
                    string value = input.Value;

                    if (Ref.Equal(name, input.Atoms.Name))
                    {
                        Name = compiler.CreateXPathQName(value);
                    }
                    else if (Ref.Equal(name, input.Atoms.DecimalSeparator))
                    {
                        info.NumberDecimalSeparator = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.GroupingSeparator))
                    {
                        info.NumberGroupSeparator = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.Infinity))
                    {
                        info.PositiveInfinitySymbol = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.MinusSign))
                    {
                        info.NegativeSign = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.NaN))
                    {
                        info.NaNSymbol = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.Percent))
                    {
                        info.PercentSymbol = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.PerMille))
                    {
                        info.PerMilleSymbol = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.Digit))
                    {
                        if (CheckAttribute(value.Length == 1, compiler))
                        {
                            format.digit = value[0];
                        }
                    }
                    else if (Ref.Equal(name, input.Atoms.ZeroDigit))
                    {
                        if (CheckAttribute(value.Length == 1, compiler))
                        {
                            format.zeroDigit = value[0];
                        }
                    }
                    else if (Ref.Equal(name, input.Atoms.PatternSeparator))
                    {
                        if (CheckAttribute(value.Length == 1, compiler))
                        {
                            format.patternSeparator = value[0];
                        }
                    }
                }while (input.MoveToNextAttribute());
                input.ToParent();
            }
            info.NegativeInfinitySymbol = string.Concat(info.NegativeSign, info.PositiveInfinitySymbol);
            if (Name == null)
            {
                Name = new XmlQualifiedName();
            }
            compiler.AddDecimalFormat(Name, format);
            CheckEmpty(compiler);
        }
Esempio n. 17
0
        private void CompileConditions(Compiler compiler)
        {
            NavigatorInput input     = compiler.Input;
            bool           when      = false;
            bool           otherwise = false;

            do
            {
                switch (input.NodeType)
                {
                case XPathNodeType.Element:
                    compiler.PushNamespaceScope();
                    string nspace = input.NamespaceURI;
                    string name   = input.LocalName;

                    if (Keywords.Equals(nspace, input.Atoms.XsltNamespace))
                    {
                        IfAction action = null;
                        if (Keywords.Equals(name, input.Atoms.When))
                        {
                            if (otherwise)
                            {
                                throw XsltException.Create(Res.Xslt_WhenAfterOtherwise);
                            }
                            action = compiler.CreateIfAction(IfAction.ConditionType.ConditionWhen);
                            when   = true;
                        }
                        else if (Keywords.Equals(name, input.Atoms.Otherwise))
                        {
                            if (otherwise)
                            {
                                throw XsltException.Create(Res.Xslt_DupOtherwise);
                            }
                            action    = compiler.CreateIfAction(IfAction.ConditionType.ConditionOtherwise);
                            otherwise = true;
                        }
                        else
                        {
                            throw compiler.UnexpectedKeyword();
                        }
                        AddAction(action);
                    }
                    else
                    {
                        throw compiler.UnexpectedKeyword();
                    }
                    compiler.PopScope();
                    break;

                case XPathNodeType.Comment:
                case XPathNodeType.ProcessingInstruction:
                case XPathNodeType.Whitespace:
                case XPathNodeType.SignificantWhitespace:
                    break;

                default:
                    throw XsltException.Create(Res.Xslt_InvalidContents, Keywords.s_Choose);
                }
            }while (compiler.Advance());
            if (!when)
            {
                throw XsltException.Create(Res.Xslt_NoWhen);
            }
        }
        //
        // 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);
        }
Esempio n. 19
0
        //
        // Constructor
        //
        internal NavigatorInput(XPathNavigator navigator, string baseUri, InputScope rootScope)
        {
            if (navigator == null)
            {
                throw new ArgumentNullException(nameof(navigator));
            }
            if (baseUri == null)
            {
                throw new ArgumentNullException(nameof(baseUri));
            }
            Debug.Assert(navigator.NameTable != null);
            _Next = null;
            _Href = baseUri;
            _Atoms = new KeywordsTable(navigator.NameTable);
            _Navigator = navigator;
            _Manager = new InputScopeManager(_Navigator, rootScope);
            _PositionInfo = PositionInfo.GetPositionInfo(_Navigator);

            /*BeginReading:*/
            AssertInput();
            if (NodeType == XPathNodeType.Root)
            {
                _Navigator.MoveToFirstChild();
            }
        }
        internal void PopInputDocument() {
            Debug.Assert(this.input != null);
            Debug.Assert(this.input.Atoms == this.atoms);

            NavigatorInput lastInput = this.input;

            this.input     = lastInput.Next;
            lastInput.Next = null;

            if (this.input != null) {
                this.atoms        = this.input.Atoms;
                this.scopeManager = this.input.InputScopeManager;
            }
            else {
                this.atoms        = null;
                this.scopeManager = null;
            }

            RemoveDocumentURI(lastInput.Href);
            lastInput.Close();
        }