Inheritance: System.Xml.XmlWriter
        /// <summary>
        /// End construction of an Rtf and return it as an RtfNavigator.  Return previous XmlQueryOutput object.
        /// </summary>
        public XPathNavigator EndRtfConstruction(out XmlQueryOutput output) {
            XmlEventCache events;

            events = (XmlEventCache) this.output.Writer;

            // Restore previous XmlQueryOutput
            output = this.output = this.stkOutput.Pop();

            // Return Rtf as an RtfNavigator
            events.EndEvents();
            return new RtfTreeNavigator(events, this.nameTableQuery);
        }
        /// <summary>
        /// Start construction of an Rtf. Return a new XmlQueryOutput object that will be used to construct this Rtf.
        /// </summary>
        public void StartRtfConstruction(string baseUri, out XmlQueryOutput output) {
            // Push current writer
            this.stkOutput.Push(this.output);

            // Create new XmlQueryOutput over an Rtf writer
            output = this.output = new XmlQueryOutput(this, new XmlEventCache(baseUri, true));
        }
        /// <summary>
        /// End construction of a nested sequence of items and return the items as an IList<XPathItem>
        /// internal class.  Return previous XmlQueryOutput.
        /// </summary>
        public IList<XPathItem> EndSequenceConstruction(out XmlQueryOutput output) {
            IList<XPathItem> seq = ((XmlCachedSequenceWriter) this.output.SequenceWriter).ResultSequence;

            // Restore previous XmlQueryOutput
            output = this.output = this.stkOutput.Pop();

            return seq;
        }
        /// <summary>
        /// Start construction of a nested sequence of items. Return a new XmlQueryOutput that will be
        /// used to construct this new sequence.
        /// </summary>
        public void StartSequenceConstruction(out XmlQueryOutput output) {
            // Push current writer
            this.stkOutput.Push(this.output);

            // Create new writers
            output = this.output = new XmlQueryOutput(this, new XmlCachedSequenceWriter());
        }
        //-----------------------------------------------
        // Constructors
        //-----------------------------------------------

        /// <summary>
        /// This constructor is internal so that external users cannot construct it (and therefore we do not have to test it separately).
        /// </summary>
        internal XmlQueryRuntime(XmlILCommand cmd, object defaultDataSource, XmlResolver dataSources, XsltArgumentList argList, XmlSequenceWriter seqWrt) {
            Debug.Assert(cmd != null, "Command object must be non-null");
            string[] names = cmd.Names;
            Int32Pair[] filters = cmd.Filters;
            WhitespaceRuleLookup wsRules;
            int i;

            this.cmd = cmd;

            // Early-Bound Library Objects
            wsRules = (cmd.WhitespaceRules.Count != 0) ? new WhitespaceRuleLookup(cmd.WhitespaceRules) : null;
            this.ctxt = new XmlQueryContext(this, defaultDataSource, dataSources, argList, wsRules);
            this.xsltLib = null;
            this.earlyInfo = cmd.EarlyBound;
            this.earlyObjects = (this.earlyInfo != null) ? new object[earlyInfo.Length] : null;

            // Global variables and parameters
            this.globalNames = cmd.GlobalNames;
            this.globalValues = (this.globalNames != null) ? new object[this.globalNames.Length] : null;

            // Names
            this.nameTableQuery = this.ctxt.QueryNameTable;
            this.atomizedNames = null;

            if (names != null) {
                // Atomize all names in "nameTableQuery".  Use names from the default data source's
                // name table when possible.
                XmlNameTable nameTableDefault = ctxt.DefaultNameTable;
                this.atomizedNames = new string[names.Length];

                if (nameTableDefault != this.nameTableQuery && nameTableDefault != null) {
                    // Ensure that atomized names from the default data source are added to the
                    // name table used in this query
                    for (i = 0; i < names.Length; i++) {
                        string name = nameTableDefault.Get(names[i]);
                        this.atomizedNames[i] = this.nameTableQuery.Add(name ?? names[i]);
                    }
                }
                else {
                    // Enter names into nametable used in this query
                    for (i = 0; i < names.Length; i++)
                        this.atomizedNames[i] = this.nameTableQuery.Add(names[i]);
                }
            }

            // Name filters
            this.filters = null;
            if (filters != null) {
                // Construct name filters.  Each pair of integers in the filters[] array specifies the
                // (localName, namespaceUri) of the NameFilter to be created.
                this.filters = new XmlNavigatorFilter[filters.Length];

                for (i = 0; i < filters.Length; i++)
                    this.filters[i] = XmlNavNameFilter.Create(this.atomizedNames[filters[i].Left], this.atomizedNames[filters[i].Right]);
            }

            // Prefix maping lists
            this.prefixMappingsList = cmd.PrefixMappingsList;

            // Xml types
            this.types = cmd.Types;

            // Xml collations
            this.collations = cmd.Collations;

            // Document ordering
            this.docOrderCmp = new DocumentOrderComparer();

            // Indexes
            this.indexes = null;

            // Output construction
            this.stkOutput = new Stack<XmlQueryOutput>(16);
            this.output = new XmlQueryOutput(this, seqWrt);
        }
Example #6
0
        //-----------------------------------------------
        // Constructors
        //-----------------------------------------------

        /// <summary>
        /// This constructor is internal so that external users cannot construct it (and therefore we do not have to test it separately).
        /// </summary>
        internal XmlQueryRuntime(XmlQueryStaticData data, object defaultDataSource, XmlResolver dataSources, XsltArgumentList argList, XmlSequenceWriter seqWrt)
        {
            Debug.Assert(data != null);
            string[] names = data.Names;
            Int32Pair[] filters = data.Filters;
            WhitespaceRuleLookup wsRules;
            int i;

            // Early-Bound Library Objects
            wsRules = (data.WhitespaceRules != null && data.WhitespaceRules.Count != 0) ? new WhitespaceRuleLookup(data.WhitespaceRules) : null;
            _ctxt = new XmlQueryContext(this, defaultDataSource, dataSources, argList, wsRules);
            _xsltLib = null;
            _earlyInfo = data.EarlyBound;
            _earlyObjects = (_earlyInfo != null) ? new object[_earlyInfo.Length] : null;

            // Global variables and parameters
            _globalNames = data.GlobalNames;
            _globalValues = (_globalNames != null) ? new object[_globalNames.Length] : null;

            // Names
            _nameTableQuery = _ctxt.QueryNameTable;
            _atomizedNames = null;

            if (names != null)
            {
                // Atomize all names in "nameTableQuery".  Use names from the default data source's
                // name table when possible.
                XmlNameTable nameTableDefault = _ctxt.DefaultNameTable;
                _atomizedNames = new string[names.Length];

                if (nameTableDefault != _nameTableQuery && nameTableDefault != null)
                {
                    // Ensure that atomized names from the default data source are added to the
                    // name table used in this query
                    for (i = 0; i < names.Length; i++)
                    {
                        string name = nameTableDefault.Get(names[i]);
                        _atomizedNames[i] = _nameTableQuery.Add(name ?? names[i]);
                    }
                }
                else
                {
                    // Enter names into nametable used in this query
                    for (i = 0; i < names.Length; i++)
                        _atomizedNames[i] = _nameTableQuery.Add(names[i]);
                }
            }

            // Name filters
            _filters = null;
            if (filters != null)
            {
                // Construct name filters.  Each pair of integers in the filters[] array specifies the
                // (localName, namespaceUri) of the NameFilter to be created.
                _filters = new XmlNavigatorFilter[filters.Length];

                for (i = 0; i < filters.Length; i++)
                    _filters[i] = XmlNavNameFilter.Create(_atomizedNames[filters[i].Left], _atomizedNames[filters[i].Right]);
            }

            // Prefix maping lists
            _prefixMappingsList = data.PrefixMappingsList;

            // Xml types
            _types = data.Types;

            // Xml collations
            _collations = data.Collations;

            // Document ordering
            _docOrderCmp = new DocumentOrderComparer();

            // Indexes
            _indexes = null;

            // Output construction
            _stkOutput = new Stack<XmlQueryOutput>(16);
            _output = new XmlQueryOutput(this, seqWrt);
        }