private PrefixQName       qname; // When we not have AVTs at all we can do this. null otherwise.

        private static PrefixQName CreateAttributeQName(string name, string nsUri, InputScopeManager manager) {
            // if name == "xmlns" we don't need to generate this attribute.
            // to avoid i'ts generation we can return false and not add AtributeCation to it's parent container action
            // for now not creating this.qname will do the trick at execution time
            if (name  == "xmlns") return null;
            if (nsUri == XmlReservedNs.NsXmlNs) {
                throw XsltException.Create(Res.Xslt_ReservedNS, nsUri);
            }

            PrefixQName qname = new PrefixQName();
            qname.SetQName(name);

            qname.Namespace = nsUri != null ? nsUri : manager.ResolveXPathNamespace(qname.Prefix);

            if (qname.Prefix.StartsWith("xml", StringComparison.Ordinal)) {
                if (qname.Prefix.Length == 3) { // prefix == "xml"
                    if (qname.Namespace == XmlReservedNs.NsXml && (qname.Name == "lang" || qname.Name == "space")) {
                        // preserve prefix for xml:lang and xml:space
                    }
                    else {
                        qname.ClearPrefix();
                    }
                }
                else if (qname.Prefix == "xmlns") {
                    if (qname.Namespace == XmlReservedNs.NsXmlNs) {
                        // if NS wasn't specified we have to use prefix to find it and this is imposible for 'xmlns' 
                        throw XsltException.Create(Res.Xslt_InvalidPrefix, qname.Prefix);
                    }
                    else {
                        qname.ClearPrefix();
                    }
                }
            }
            return qname;
        }
        internal override void Compile(Compiler compiler)
        {
            CompileAttributes(compiler);
            CheckRequiredAttribute(compiler, this.nameAvt, "name");

            this.name  = PrecalculateAvt(ref this.nameAvt);
            this.nsUri = PrecalculateAvt(ref this.nsAvt);

            // if both name and ns are not AVT we can calculate qname at compile time and will not need namespace manager anymore
            if (this.nameAvt == null && this.nsAvt == null)
            {
                if (this.name != "xmlns")
                {
                    this.qname = CreateAttributeQName(this.name, this.nsUri, compiler.CloneScopeManager());
                }
            }
            else
            {
                this.manager = compiler.CloneScopeManager();
            }

            if (compiler.Recurse())
            {
                CompileTemplate(compiler);
                compiler.ToParent();
            }
        }
        //
        // 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();
            }
        }
Beispiel #4
0
        internal override void Compile(Compiler compiler)
        {
            CompileAttributes(compiler);
            CheckRequiredAttribute(compiler, _nameAvt, "name");

            _name = PrecalculateAvt(ref _nameAvt);
            _nsUri = PrecalculateAvt(ref _nsAvt);

            // if both name and ns are not AVT we can calculate qname at compile time and will not need namespace manager anymore
            if (_nameAvt == null && _nsAvt == null)
            {
                if (_name != "xmlns")
                {
                    _qname = CreateElementQName(_name, _nsUri, compiler.CloneScopeManager());
                }
            }
            else
            {
                _manager = compiler.CloneScopeManager();
            }

            if (compiler.Recurse())
            {
                Debug.Assert(_empty == false);
                CompileTemplate(compiler);
                compiler.ToParent();
            }
            _empty = (this.containedActions == null);
        }
Beispiel #5
0
        internal override void Compile(Compiler compiler)
        {
            CompileAttributes(compiler);
            CheckRequiredAttribute(compiler, this.nameAvt, Keywords.s_Name);

            this.name  = PrecalculateAvt(ref this.nameAvt);
            this.nsUri = PrecalculateAvt(ref this.nsAvt);

            // if both name and ns are not AVT we can calculate qname at compile time and will not need namespace manager anymore
            if (this.nameAvt == null && this.nsAvt == null)
            {
                if (this.name != Keywords.s_Xmlns)
                {
                    this.qname = CreateElementQName(this.name, this.nsUri, compiler.CloneScopeManager());
                }
            }
            else
            {
                this.manager = compiler.CloneScopeManager();
            }

            if (compiler.Recurse())
            {
                Debug.Assert(this.empty == false);
                CompileTemplate(compiler);
                compiler.ToParent();
            }
            this.empty = (this.containedActions == null);
        }
Beispiel #6
0
        internal override void Compile(Compiler compiler)
        {
            CompileAttributes(compiler);
            CheckRequiredAttribute(compiler, _nameAvt, "name");

            _name  = PrecalculateAvt(ref _nameAvt);
            _nsUri = PrecalculateAvt(ref _nsAvt);

            // if both name and ns are not AVT we can calculate qname at compile time and will not need namespace manager anymore
            if (_nameAvt == null && _nsAvt == null)
            {
                if (_name != "xmlns")
                {
                    _qname = CreateElementQName(_name, _nsUri, compiler.CloneScopeManager());
                }
            }
            else
            {
                _manager = compiler.CloneScopeManager();
            }

            if (compiler.Recurse())
            {
                Debug.Assert(_empty == false);
                CompileTemplate(compiler);
                compiler.ToParent();
            }
            _empty = (this.containedActions == null);
        }
Beispiel #7
0
 internal InputScopeManager Clone()
 {
     InputScopeManager manager = new InputScopeManager(_navigator, null);
     manager._scopeStack = _scopeStack;
     manager._defaultNS = _defaultNS;
     return manager;
 }
Beispiel #8
0
        internal InputScopeManager Clone()
        {
            InputScopeManager manager = new InputScopeManager(_navigator, null);

            manager._scopeStack = _scopeStack;
            manager._defaultNS  = _defaultNS;
            return(manager);
        }
Beispiel #9
0
        internal InputScopeManager Clone()
        {
            InputScopeManager manager = new InputScopeManager(this.navigator, null);

            manager.scopeStack = this.scopeStack;
            manager.defaultNS  = this.defaultNS;
            return(manager);
        }
Beispiel #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;
        }
Beispiel #11
0
        private PrefixQName qname;       // When we not have AVTs at all we can do this. null otherwise.

        private static PrefixQName CreateAttributeQName(string name, string nsUri, InputScopeManager manager)
        {
            // if name == "xmlns" we don't need to generate this attribute.
            // to avoid i'ts generation we can return false and not add AtributeCation to it's parent container action
            // for now not creating this.qname will do the trick at execution time
            if (name == "xmlns")
            {
                return(null);
            }
            if (nsUri == XmlReservedNs.NsXmlNs)
            {
                throw XsltException.Create(Res.Xslt_ReservedNS, nsUri);
            }

            PrefixQName qname = new PrefixQName();

            qname.SetQName(name);

            qname.Namespace = nsUri != null ? nsUri : manager.ResolveXPathNamespace(qname.Prefix);

            if (qname.Prefix.StartsWith("xml", StringComparison.Ordinal))
            {
                if (qname.Prefix.Length == 3)   // prefix == "xml"
                {
                    if (qname.Namespace == XmlReservedNs.NsXml && (qname.Name == "lang" || qname.Name == "space"))
                    {
                        // preserve prefix for xml:lang and xml:space
                    }
                    else
                    {
                        qname.ClearPrefix();
                    }
                }
                else if (qname.Prefix == "xmlns")
                {
                    if (qname.Namespace == XmlReservedNs.NsXmlNs)
                    {
                        // if NS wasn't specified we have to use prefix to find it and this is imposible for 'xmlns'
                        throw XsltException.Create(Res.Xslt_InvalidPrefix, qname.Prefix);
                    }
                    else
                    {
                        qname.ClearPrefix();
                    }
                }
            }
            return(qname);
        }
        private static PrefixQName CreateElementQName(string name, string nsUri, InputScopeManager manager) {
            if (nsUri == XmlReservedNs.NsXmlNs) {
                throw XsltException.Create(Res.Xslt_ReservedNS, nsUri);
            }

            PrefixQName qname = new PrefixQName();
            qname.SetQName(name);

            if (nsUri == null) {
                qname.Namespace = manager.ResolveXmlNamespace(qname.Prefix);
            }
            else {
                qname.Namespace = nsUri;
            }
            return qname;
        }
        private XmlDataType ParseDataType(string value, InputScopeManager manager) {
            if(value == null) { // Avt is not constant, or attribute wasn't defined
                return XmlDataType.Text; 
            }
            if (value == Keywords.s_Text) {
                return XmlDataType.Text;
            }
            if (value == Keywords.s_Number) {
                return XmlDataType.Number; 
            }
            String prefix, localname;
            PrefixQName.ParseQualifiedName(value, out prefix, out localname);
			manager.ResolveXmlNamespace(prefix);
            if (prefix.Length == 0 && ! this.forwardCompatibility) {
                throw XsltException.Create(Res.Xslt_InvalidAttrValue, Keywords.s_DataType, value); 
            }
            return XmlDataType.Text;
        }
Beispiel #14
0
        private static PrefixQName CreateElementQName(string name, string nsUri, InputScopeManager manager)
        {
            if (nsUri == XmlReservedNs.NsXmlNs)
            {
                throw XsltException.Create(SR.Xslt_ReservedNS, nsUri);
            }

            PrefixQName qname = new PrefixQName();

            qname.SetQName(name);

            if (nsUri == null)
            {
                qname.Namespace = manager.ResolveXmlNamespace(qname.Prefix);
            }
            else
            {
                qname.Namespace = nsUri;
            }
            return(qname);
        }
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);
            CheckRequiredAttribute(compiler, this.nameAvt, "name");

            this.name  = PrecalculateAvt(ref this.nameAvt);
            this.nsUri = PrecalculateAvt(ref this.nsAvt  );

            // if both name and ns are not AVT we can calculate qname at compile time and will not need namespace manager anymore
            if (this.nameAvt == null && this.nsAvt == null) {
                if(this.name != "xmlns") {
                    this.qname = CreateAttributeQName(this.name, this.nsUri, compiler.CloneScopeManager());                    
                }
            }
            else {
                this.manager = compiler.CloneScopeManager();
            }

            if (compiler.Recurse()) {
                CompileTemplate(compiler);
                compiler.ToParent();
            }
        }
Beispiel #16
0
        internal override void Compile(Compiler compiler)
        {
            CompileAttributes(compiler);
            CheckEmpty(compiler);
            if (selectKey == Compiler.InvalidQueryKey)
            {
                selectKey = compiler.AddQuery(".");
            }

            this.forwardCompatibility = compiler.ForwardCompatibility;
            this.manager = compiler.CloneScopeManager();

            this.lang      = ParseLang(PrecalculateAvt(ref this.langAvt));
            this.dataType  = ParseDataType(PrecalculateAvt(ref this.dataTypeAvt), manager);
            this.order     = ParseOrder(PrecalculateAvt(ref this.orderAvt));
            this.caseOrder = ParseCaseOrder(PrecalculateAvt(ref this.caseOrderAvt));

            if (this.langAvt == null && this.dataTypeAvt == null && this.orderAvt == null && this.caseOrderAvt == null)
            {
                this.sort = new Sort(this.selectKey, this.lang, this.dataType, this.order, this.caseOrder);
            }
        }
Beispiel #17
0
        internal override void Compile(Compiler compiler)
        {
            CompileAttributes(compiler);
            CheckEmpty(compiler);
            if (_selectKey == Compiler.InvalidQueryKey)
            {
                _selectKey = compiler.AddQuery(".");
            }

            _forwardCompatibility = compiler.ForwardCompatibility;
            _manager = compiler.CloneScopeManager();

            _lang      = ParseLang(PrecalculateAvt(ref _langAvt));
            _dataType  = ParseDataType(PrecalculateAvt(ref _dataTypeAvt), _manager);
            _order     = ParseOrder(PrecalculateAvt(ref _orderAvt));
            _caseOrder = ParseCaseOrder(PrecalculateAvt(ref _caseOrderAvt));

            if (_langAvt == null && _dataTypeAvt == null && _orderAvt == null && _caseOrderAvt == null)
            {
                _sort = new Sort(_selectKey, _lang, _dataType, _order, _caseOrder);
            }
        }
Beispiel #18
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();
        }
Beispiel #19
0
        private XmlDataType ParseDataType(string value, InputScopeManager manager)
        {
            if (value == null)
            { // Avt is not constant, or attribute wasn't defined
                return(XmlDataType.Text);
            }
            if (value == "text")
            {
                return(XmlDataType.Text);
            }
            if (value == "number")
            {
                return(XmlDataType.Number);
            }
            String prefix, localname;

            PrefixQName.ParseQualifiedName(value, out prefix, out localname);
            manager.ResolveXmlNamespace(prefix);
            if (prefix.Length == 0 && !_forwardCompatibility)
            {
                throw XsltException.Create(SR.Xslt_InvalidAttrValue, "data-type", value);
            }
            return(XmlDataType.Text);
        }
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);
            CheckRequiredAttribute(compiler, this.nameAvt, Keywords.s_Name);

            this.name  = PrecalculateAvt(ref this.nameAvt);
            this.nsUri = PrecalculateAvt(ref this.nsAvt  );

            // if both name and ns are not AVT we can calculate qname at compile time and will not need namespace manager anymore
            if (this.nameAvt == null && this.nsAvt == null) {
                if(this.name != Keywords.s_Xmlns) {
                    this.qname = CreateElementQName(this.name, this.nsUri, compiler.CloneScopeManager());                    
                }
            }
            else {
                this.manager = compiler.CloneScopeManager();
            }

            if (compiler.Recurse()) {
                Debug.Assert(this.empty == false);
                CompileTemplate(compiler);
                compiler.ToParent();
            }
            this.empty = (this.containedActions == null) ;
        }
Beispiel #21
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();
        }
Beispiel #22
0
 internal TheQuery(CompiledXpathExpr compiledQuery, InputScopeManager manager)
 {
     _CompiledQuery = compiledQuery;
     _ScopeManager  = manager.Clone();
 }
Beispiel #23
0
 internal TheQuery(CompiledXpathExpr compiledQuery, InputScopeManager manager)
 {
     _CompiledQuery = compiledQuery;
     _ScopeManager = manager.Clone();
 }
Beispiel #24
0
 internal void Reinitialize(InputScopeManager manager, Processor processor)
 {
     this.manager   = manager;
     this.processor = processor;
 }
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);
            CheckEmpty(compiler);
            if (selectKey == Compiler.InvalidQueryKey) {
                selectKey = compiler.AddQuery(".");
            }

            this.forwardCompatibility = compiler.ForwardCompatibility;
            this.manager = compiler.CloneScopeManager();

            this.lang      = ParseLang(     PrecalculateAvt(ref this.langAvt     ));
            this.dataType  = ParseDataType( PrecalculateAvt(ref this.dataTypeAvt ), manager);
            this.order     = ParseOrder(    PrecalculateAvt(ref this.orderAvt    ));
            this.caseOrder = ParseCaseOrder(PrecalculateAvt(ref this.caseOrderAvt));

            if(this.langAvt == null && this.dataTypeAvt == null && this.orderAvt == null && this.caseOrderAvt == null) {
                this.sort = new Sort(this.selectKey, this.lang, this.dataType, this.order, this.caseOrder);
            }
        }
        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();
        }
Beispiel #27
0
 internal void Reinitialize(InputScopeManager manager, Processor processor)
 {
     _manager   = manager;
     _processor = processor;
 }
Beispiel #28
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;
        }
Beispiel #29
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();
            }
        }
Beispiel #30
0
        internal override void Compile(Compiler compiler)
        {
            CompileAttributes(compiler);
            CheckEmpty(compiler);
            if (_selectKey == Compiler.InvalidQueryKey)
            {
                _selectKey = compiler.AddQuery(".");
            }

            _forwardCompatibility = compiler.ForwardCompatibility;
            _manager = compiler.CloneScopeManager();

            _lang = ParseLang(PrecalculateAvt(ref _langAvt));
            _dataType = ParseDataType(PrecalculateAvt(ref _dataTypeAvt), _manager);
            _order = ParseOrder(PrecalculateAvt(ref _orderAvt));
            _caseOrder = ParseCaseOrder(PrecalculateAvt(ref _caseOrderAvt));

            if (_langAvt == null && _dataTypeAvt == null && _orderAvt == null && _caseOrderAvt == null)
            {
                _sort = new Sort(_selectKey, _lang, _dataType, _order, _caseOrder);
            }
        }
 internal void Recycle() {
     manager = null;
     processor = null;
 }
 internal XsltCompileContext(InputScopeManager manager, Processor processor) : base(/*dummy*/false) {
     this.manager   = manager;
     this.processor = processor;
 }
Beispiel #33
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();
        }
Beispiel #34
0
 internal XsltCompileContext(InputScopeManager manager, Processor processor) : base(/*dummy*/ false)
 {
     this.manager   = manager;
     this.processor = processor;
 }
Beispiel #35
0
 internal void Recycle()
 {
     manager   = null;
     processor = null;
 }
 internal void Reinitialize(InputScopeManager manager, Processor processor) {
     this.manager = manager;
     this.processor = processor;
 }
 internal InputScopeManager Clone() {
     InputScopeManager manager = new InputScopeManager(this.navigator, null);
     manager.scopeStack = this.scopeStack;
     manager.defaultNS  = this.defaultNS;
     return manager;
 }
Beispiel #38
0
 internal void Reinitialize(InputScopeManager manager, Processor processor)
 {
     _manager = manager;
     _processor = processor;
 }