/// <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());
        }
Beispiel #3
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);
        }
Beispiel #4
0
 /// <summary>
 /// Forward call to wrapped writer.
 /// </summary>
 public override void Close()
 {
     _wrapped.Close();
 }
Beispiel #5
0
 public void TheEnd()
 {
     _wr.Close();
 }
Beispiel #6
0
 public override void EndTree()
 {
     // Add newly constructed document to sequence
     _writer.Close();
     _seqTyped.Add(_doc.CreateNavigator());
 }