示例#1
0
 public override XmlRawWriter StartTree(XPathNodeType rootType, IXmlNamespaceResolver nsResolver, XmlNameTable nameTable)
 {
     // Build XPathDocument
     // If rootType != XPathNodeType.Root, then build an XQuery fragment
     _doc    = new XPathDocument(nameTable);
     _writer = _doc.LoadFromWriter(XPathDocument.LoadFlags.AtomizeNames | (rootType == XPathNodeType.Root ? XPathDocument.LoadFlags.None : XPathDocument.LoadFlags.Fragment), string.Empty);
     _writer.NamespaceResolver = nsResolver;
     return(_writer);
 }
        /// <summary>
        /// Create a document containing a root node and a single text node child with "text" as its text value.
        /// This method is thread-safe, and is always guaranteed to return the exact same document, no matter how many
        /// threads have called it concurrently.
        /// </summary>
        public XPathNavigator GetNavigator(string text, string baseUri, XmlNameTable nameTable)
        {
            if (this.cache == null)
            {
                // Create XPathDocument
                XPathDocument doc    = new XPathDocument(nameTable);
                XmlRawWriter  writer = doc.LoadFromWriter(XPathDocument.LoadFlags.AtomizeNames, baseUri);
                writer.WriteString(text);
                writer.Close();

                this.cache = doc;
            }

            return(((XPathDocument)this.cache).CreateNavigator());
        }
        /// <summary>
        /// Create a document from the cache of events.  If a document has already been created previously, return it.
        /// This method is thread-safe, and is always guaranteed to return the exact same document, no matter how many
        /// threads have called it concurrently.
        /// </summary>
        public XPathNavigator GetNavigator(XmlEventCache events, XmlNameTable nameTable)
        {
            if (this.cache == null)
            {
                // Create XPathDocument from event cache
                XPathDocument doc    = new XPathDocument(nameTable);
                XmlRawWriter  writer = doc.LoadFromWriter(XPathDocument.LoadFlags.AtomizeNames | (events.HasRootNode ? XPathDocument.LoadFlags.None : XPathDocument.LoadFlags.Fragment), events.BaseUri);

                events.EventsToWriter(writer);
                writer.Close();

                this.cache = doc;
            }

            return(((XPathDocument)this.cache).CreateNavigator());
        }
示例#4
0
        //------------------------------------------------------------------------
        // ToNode (internal type to internal type)
        //------------------------------------------------------------------------

        public static XPathNavigator ToNode(XPathItem item)
        {
            XsltLibrary.CheckXsltValue(item);

            if (!item.IsNode)
            {
                // Create Navigator over text node containing string value of item
                XPathDocument doc    = new XPathDocument();
                XmlRawWriter  writer = doc.LoadFromWriter(XPathDocument.LoadFlags.AtomizeNames, string.Empty);
                writer.WriteString(ToString(item));
                writer.Close();
                return(doc.CreateNavigator());
            }

            RtfNavigator?rtf = item as RtfNavigator;

            if (rtf != null)
            {
                return(rtf.ToNavigator());
            }

            return((XPathNavigator)item);
        }
示例#5
0
 internal NavigatorOutput(string baseUri)
 {
     _doc = new XPathDocument();
     _wr  = _doc.LoadFromWriter(XPathDocument.LoadFlags.AtomizeNames, baseUri);
 }