LoadFromWriter() private method

Create a writer that can be used to create nodes in this document. The root node will be assigned "baseUri", and flags can be passed to indicate that names should be atomized by the builder and/or a fragment should be created.
private LoadFromWriter ( LoadFlags flags, string baseUri ) : XmlRawWriter
flags LoadFlags
baseUri string
return XmlRawWriter
Ejemplo n.º 1
0
 /// <summary>
 /// Start construction of a new Xml tree (document or fragment).
 /// </summary>
 public override XmlRawWriter StartTree(XPathNodeType rootType, IXmlNamespaceResolver nsResolver, XmlNameTable nameTable) {
     // Build XPathDocument
     // If rootType != XPathNodeType.Root, then build an XQuery fragment
     this.doc = new XPathDocument(nameTable);
     this.writer = doc.LoadFromWriter(XPathDocument.LoadFlags.AtomizeNames | (rootType == XPathNodeType.Root ? XPathDocument.LoadFlags.None : XPathDocument.LoadFlags.Fragment), string.Empty);
     this.writer.NamespaceResolver = nsResolver;
     return this.writer;
 }
 internal NavigatorOutput(string baseUri) {
     doc = new XPathDocument();
     this.wr = doc.LoadFromWriter(XPathDocument.LoadFlags.AtomizeNames, baseUri);
 }
Ejemplo n.º 3
0
        /// <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();
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 5
0
        /// <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();
        }