WriteDocType() public abstract méthode

public abstract WriteDocType ( string name, string pubid, string sysid, string subset ) : void
name string
pubid string
sysid string
subset string
Résultat void
Exemple #1
0
		public void WriteDocumentTo(XmlWriter writer)
		{
			writer.WriteDocType("html", "-//W3C//DTD XHTML 1.1//EN", null, null);

			writer.WriteStartElement("html");
			writer.WriteAttributeString("xmlns", "http://www.w3.org/1999/xhtml");

			writer.WriteStartElement("head");
			if (Document.Metadata.ContainsKey("Title")) {
				writer.WriteStartElement("title");
				writer.WriteString(Document.Metadata["Title"].ToString());
				writer.WriteEndElement();
			}
			writer.WriteStartElement("meta");
			writer.WriteAttributeString("http-equiv", "ContentType");
			writer.WriteAttributeString("context", "text/xhtml; charset=utf-8");
			writer.WriteEndElement();
			writer.WriteEndElement(); // head

			writer.WriteStartElement("body");
			WriteTo(writer);
			writer.WriteEndElement(); // body

			writer.WriteEndElement(); // html
		}
 public override void WriteTo(XmlWriter writer)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     writer.WriteDocType(this.name, this.publicId, this.systemId, this.internalSubset);
 }
Exemple #3
0
 public override void Write(System.Xml.XmlWriter writer)
 {
     writer.WriteStartDocument();
     writer.WriteDocType("plist", "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
     writer.WriteStartElement("plist");
     writer.WriteAttributeString("version", version);
     Root.Write(writer);
     writer.WriteEndDocument();
 }
			public ENMLWriter()
			{
				Contents = new Utf8StringWriter();
				XmlWriterSettings settings = new XmlWriterSettings();
				settings.ConformanceLevel = ConformanceLevel.Auto;
				//writer = XmlWriter.Create(Contents, settings)
				writer = XmlWriter.Create(Contents);
				writer.WriteDocType("en-note", null, "http://xml.evernote.com/pub/enml2.dtd", null);
			}
Exemple #5
0
 public static void WriteXmlWriter (object value, XmlWriter writer)
 {
     writer.WriteStartDocument();
     writer.WriteDocType("plist", "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
     writer.WriteStartElement("plist");
     writer.WriteAttributeString("version", "1.0");
     new Plist().Compose(value, writer);
     writer.WriteEndElement();
     writer.WriteEndDocument();
 }
Exemple #6
0
        // Constructor
        public Hxt(string filePath, Encoding encoding)
        {
            Disposed = false;

            XmlWriterSettings settings = new XmlWriterSettings { Indent = true, NewLineChars = Environment.NewLine, Encoding = encoding, };
            writer = XmlWriter.Create(filePath, settings);

            // Write header
            writer.WriteStartDocument();
            writer.WriteDocType("HelpTOC", null, "MS-Help://Hx/Resources/HelpTOC.DTD", null);
            writer.WriteStartElement("HelpTOC");
            writer.WriteAttributeString("DTDVersion", "1.0");
            writer.Flush();
        }
    private void WriteNodeSingle(XmlReader reader, XmlWriter writer) {
      Contract.Requires(reader != null);
      Contract.Requires(writer != null);

      switch (reader.NodeType) {
        case XmlNodeType.Element:
          this.WriteElement(reader, writer);
          break;
        case XmlNodeType.Text:
          this.WriteText(reader, writer);
          break;
        case XmlNodeType.Whitespace:
        case XmlNodeType.SignificantWhitespace:
          this.WriteWhitespace(reader, writer);
          break;
        case XmlNodeType.CDATA:
          this.WriteCDATA(reader, writer);
          break;
        case XmlNodeType.EntityReference:
          Contract.Assume(false, "entityref not supported");
          writer.WriteString(reader.Name);
          break;
        case XmlNodeType.XmlDeclaration:
        case XmlNodeType.ProcessingInstruction:
          var pinstr = reader.Name;
          Contract.Assume(!String.IsNullOrEmpty(pinstr));
          writer.WriteProcessingInstruction(pinstr, reader.Value);
          break;
        case XmlNodeType.DocumentType:
          writer.WriteDocType(
              reader.Name,
              reader.GetAttribute("PUBLIC"),
              reader.GetAttribute("SYSTEM"),
              reader.Value);
          break;
        case XmlNodeType.Comment:
          WriteComment(reader, writer);
          break;
        case XmlNodeType.EndElement:
          this.WriteEndElement(reader, writer);
          break;
      }
    }
Exemple #8
0
 internal static void Save(XmlWriter writer, IEnumerable<IShape> shapes, Size size)
 {
     if (writer == null)
         throw new ArgumentNullException ("writer");
     writer.WriteStartDocument (false);
     writer.WriteDocType ("svg", "-//W3C//Dtd SVG 1.1//EN",
                         "http://www.w3.org/Graphics/SVG/1.1/Dtd/svg11.dtd", null);
     writer.WriteStartElement ("svg", "http://www.w3.org/2000/svg");
     writer.WriteAttributeString ("width", SafeString (size.Width));
     writer.WriteAttributeString ("height", SafeString (size.Height));
     writer.WriteAttributeString ("version", "1.1");
     writer.WriteAttributeString ("preserveAspectratio", "xMidYMid");
     if (shapes != null)
         foreach (var s in shapes) {
             var pers = s as IPersistableShape;
             if (pers != null)
                 pers.SvgSave (writer);
         }
     writer.WriteEndElement ();
 }
        public SVGDocument(double width, double height)
        {
            m_stream = new MemoryStream();
            //m_writer = XmlWriter.Create(m_stream);
            settings.Indent = true;
            settings.IndentChars = "  ";
            settings.NewLineChars = "\r\n";
            m_writer = XmlWriter.Create(m_stream, settings);

            m_writer.WriteStartDocument();
            m_writer.WriteDocType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", null);
            m_writer.WriteStartElement("svg", "http://www.w3.org/2000/svg");
            m_writer.WriteAttributeString("version", "1.1");
            if (width == 100 && height == 100)
            {
                m_writer.WriteAttributeString("width", "100%");
                m_writer.WriteAttributeString("height", "100%");
            }
            else
            {
                m_writer.WriteAttributeString("width", width.ToString());
                m_writer.WriteAttributeString("height", height.ToString());
            }
        }
Exemple #10
0
        /// <summary>
        /// Replay all cached events to an XmlWriter.
        /// </summary>
        public void EventsToWriter(XmlWriter writer) {
            XmlEvent[] page;
            int idxPage, idxEvent;
            byte[] bytes;
            char[] chars;
            XmlRawWriter rawWriter;

            // Special-case single text node at the top-level
            if (this.singleText.Count != 0) {
                writer.WriteString(this.singleText.GetResult());
                return;
            }

            rawWriter = writer as XmlRawWriter;

            // Loop over set of pages
            for (idxPage = 0; idxPage < this.pages.Count; idxPage++) {
                page = this.pages[idxPage];

                // Loop over events in each page
                for (idxEvent = 0; idxEvent < page.Length; idxEvent++) {
                    switch (page[idxEvent].EventType) {
                        case XmlEventType.Unknown:
                            // No more events
                            Debug.Assert(idxPage + 1 == this.pages.Count);
                            return;

                        case XmlEventType.DocType:
                            writer.WriteDocType(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3, (string) page[idxEvent].Object);
                            break;

                        case XmlEventType.StartElem:
                            writer.WriteStartElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                            break;

                        case XmlEventType.StartAttr:
                            writer.WriteStartAttribute(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                            break;

                        case XmlEventType.EndAttr:
                            writer.WriteEndAttribute();
                            break;

                        case XmlEventType.CData:
                            writer.WriteCData(page[idxEvent].String1);
                            break;

                        case XmlEventType.Comment:
                            writer.WriteComment(page[idxEvent].String1);
                            break;

                        case XmlEventType.PI:
                            writer.WriteProcessingInstruction(page[idxEvent].String1, page[idxEvent].String2);
                            break;

                        case XmlEventType.Whitespace:
                            writer.WriteWhitespace(page[idxEvent].String1);
                            break;

                        case XmlEventType.String:
                            writer.WriteString(page[idxEvent].String1);
                            break;

                        case XmlEventType.Raw:
                            writer.WriteRaw(page[idxEvent].String1);
                            break;

                        case XmlEventType.EntRef:
                            writer.WriteEntityRef(page[idxEvent].String1);
                            break;

                        case XmlEventType.CharEnt:
                            writer.WriteCharEntity((char) page[idxEvent].Object);
                            break;

                        case XmlEventType.SurrCharEnt:
                            chars = (char[]) page[idxEvent].Object;
                            writer.WriteSurrogateCharEntity(chars[0], chars[1]);
                            break;

                        case XmlEventType.Base64:
                            bytes = (byte[]) page[idxEvent].Object;
                            writer.WriteBase64(bytes, 0, bytes.Length);
                            break;

                        case XmlEventType.BinHex:
                            bytes = (byte[]) page[idxEvent].Object;
                            writer.WriteBinHex(bytes, 0, bytes.Length);
                            break;

                        case XmlEventType.XmlDecl1:
                            if (rawWriter != null)
                                rawWriter.WriteXmlDeclaration((XmlStandalone) page[idxEvent].Object);
                            break;

                        case XmlEventType.XmlDecl2:
                            if (rawWriter != null)
                                rawWriter.WriteXmlDeclaration(page[idxEvent].String1);
                            break;

                        case XmlEventType.StartContent:
                            if (rawWriter != null)
                                rawWriter.StartElementContent();
                            break;

                        case XmlEventType.EndElem:
                            if (rawWriter != null)
                                rawWriter.WriteEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                            else
                                writer.WriteEndElement();
                            break;

                        case XmlEventType.FullEndElem:
                            if (rawWriter != null)
                                rawWriter.WriteFullEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                            else
                                writer.WriteFullEndElement();
                            break;

                        case XmlEventType.Nmsp:
                            if (rawWriter != null)
                                rawWriter.WriteNamespaceDeclaration(page[idxEvent].String1, page[idxEvent].String2);
                            else
                                writer.WriteAttributeString("xmlns", page[idxEvent].String1, XmlReservedNs.NsXmlNs, page[idxEvent].String2);
                            break;

                        case XmlEventType.EndBase64:
                            if (rawWriter != null)
                                rawWriter.WriteEndBase64();
                            break;

                        case XmlEventType.Close:
                            writer.Close();
                            break;

                        case XmlEventType.Flush:
                            writer.Flush();
                            break;

                        case XmlEventType.Dispose:
                            ((IDisposable)writer).Dispose();
                            break;

                        default:
                            Debug.Assert(false, "Unknown event: " + page[idxEvent].EventType);
                            break;
                    }
                }
            }

            Debug.Assert(false, "Unknown event should be added to end of event sequence.");
        }
Exemple #11
0
 public override void WriteTo(XmlWriter w)
 {
     w.WriteDocType(Name, PublicId, SystemId, InternalSubset);
 }
Exemple #12
0
 // Saves the node to the specified XmlWriter.
 public override void WriteTo(XmlWriter w)
 {
     w.WriteDocType(_name, _publicId, _systemId, _internalSubset);
 }
Exemple #13
0
 // Saves the node to the specified XmlWriter.
 public override void WriteTo(XmlWriter w)
 {
     w.WriteDocType(_name, _publicId, _systemId, _internalSubset);
 }
Exemple #14
0
        public void WriteCapabilitiesDocType(XmlWriter writer)
        {
            if (Version >= WmsVersionEnum.Version_1_3_0)
                return;

            writer.WriteDocType("WMT_MS_Capability", null, System(Version, "capabilities"), null);
        }
 public override void WriteDocType(string name, string pubid, string sysid, string subset)
 {
     CheckAsync();
     _coreWriter.WriteDocType(name, pubid, sysid, subset);
 }
Exemple #16
0
 // Saves the node to the specified XmlWriter.
 public override void WriteTo(XmlWriter w)
 {
     w.WriteDocType(name, publicId, systemId, internalSubset);
 }
			public ENMLWriter()
			{
				Contents = new Utf8StringWriter();
				writer = XmlWriter.Create(Contents);
				writer.WriteDocType("en-note", null, "http://xml.evernote.com/pub/enml2.dtd", null);
			}
        private static void WriteShallowNode(XmlReader reader, XmlWriter writer)
        {
            switch (reader.NodeType)
            {
                case XmlNodeType.Element:
                    writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                    writer.WriteAttributes(reader, true);
                    if (reader.IsEmptyElement)
                    {
                        writer.WriteEndElement();
                    }
                    return;

                case XmlNodeType.Text:
                    writer.WriteString(reader.Value);
                    return;

                case XmlNodeType.CDATA:
                    writer.WriteCData(reader.Value);
                    return;

                case XmlNodeType.ProcessingInstruction:
                    writer.WriteProcessingInstruction(reader.Name, reader.Value);
                    return;

                case XmlNodeType.Comment:
                    writer.WriteComment(reader.Value);
                    return;

                case XmlNodeType.DocumentType:
                    writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
                    return;

                case XmlNodeType.Whitespace:
                    writer.WriteWhitespace(reader.Value);
                    return;

                case XmlNodeType.SignificantWhitespace:
                    writer.WriteWhitespace(reader.Value);
                    return;

                case XmlNodeType.EndElement:
                    writer.WriteFullEndElement();
                    return;

                case XmlNodeType.XmlDeclaration:
                    writer.WriteProcessingInstruction(reader.Name, reader.Value);
                    return;
            }
            throw new InvalidOperationException("Invalid node");
        }
Exemple #19
0
 // Overriden abstract methods for outputting
 internal override void WriteTo( XmlWriter w )
 {
     w.WriteDocType( _name, string.Empty, string.Empty, _subset );
 }
Exemple #20
0
        // Writes the content (inner XML) of the current node into the provided XmlWriter.
        private async Task WriteNodeAsync(XmlWriter xtw, bool defattr)
        {
#if !SILVERLIGHT
            Debug.Assert(xtw is XmlTextWriter);
#endif
            int d = this.NodeType == XmlNodeType.None ? -1 : this.Depth;
            while (await this.ReadAsync().ConfigureAwait(false) && (d < this.Depth))
            {
                switch (this.NodeType)
                {
                case XmlNodeType.Element:
                    xtw.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI);
#if !SILVERLIGHT // Removing dependency on XmlTextWriter
                    ((XmlTextWriter)xtw).QuoteChar = this.QuoteChar;
#endif
                    xtw.WriteAttributes(this, defattr);
                    if (this.IsEmptyElement)
                    {
                        xtw.WriteEndElement();
                    }
                    break;

                case XmlNodeType.Text:
                    xtw.WriteString(await this.GetValueAsync().ConfigureAwait(false));
                    break;

                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    xtw.WriteWhitespace(await this.GetValueAsync().ConfigureAwait(false));
                    break;

                case XmlNodeType.CDATA:
                    xtw.WriteCData(this.Value);
                    break;

                case XmlNodeType.EntityReference:
                    xtw.WriteEntityRef(this.Name);
                    break;

                case XmlNodeType.XmlDeclaration:
                case XmlNodeType.ProcessingInstruction:
                    xtw.WriteProcessingInstruction(this.Name, this.Value);
                    break;

                case XmlNodeType.DocumentType:
                    xtw.WriteDocType(this.Name, this.GetAttribute("PUBLIC"), this.GetAttribute("SYSTEM"), this.Value);
                    break;

                case XmlNodeType.Comment:
                    xtw.WriteComment(this.Value);
                    break;

                case XmlNodeType.EndElement:
                    xtw.WriteFullEndElement();
                    break;
                }
            }
            if (d == this.Depth && this.NodeType == XmlNodeType.EndElement)
            {
                await ReadAsync().ConfigureAwait(false);
            }
        }
        /// <summary>
        /// Writes given property list into a designated output.
        /// </summary>
        public static void Write(XmlWriter writer, IPropertyListItem root)
        {
            if (writer == null)
                throw new ArgumentNullException("writer");

            writer.WriteStartDocument();
            writer.WriteDocType("plist", "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
            writer.WriteStartElement("plist");
            writer.WriteAttributeString("version", "1.0");
            WriteItem(writer, root);
            writer.WriteEndElement();
            writer.WriteEndDocument();
        }
        protected void TransformXml(XmlReader reader, XmlWriter writer)
        {
//            m_log.DebugFormat("[HG ASSET MAPPER]: Transforming XML");

            int sopDepth = -1;
            UserAccount creator = null;
            bool hasCreatorData = false;

            while (reader.Read())
            {
//                Console.WriteLine("Depth: {0}, name {1}", reader.Depth, reader.Name);

                switch (reader.NodeType)
                {
                    case XmlNodeType.Attribute:
//                    Console.WriteLine("FOUND ATTRIBUTE {0}", reader.Name);
                    writer.WriteAttributeString(reader.Prefix, reader.Name, reader.NamespaceURI, reader.Value);
                    break;

                    case XmlNodeType.CDATA:
                    writer.WriteCData(reader.Value);
                    break;

                    case XmlNodeType.Comment:
                    writer.WriteComment(reader.Value);
                    break;

                    case XmlNodeType.DocumentType:
                    writer.WriteDocType(reader.Name, reader.Value, null, null);
                    break;

                    case XmlNodeType.Element: 
//                    m_log.DebugFormat("Depth {0} at element {1}", reader.Depth, reader.Name);

                    writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);

                    if (reader.HasAttributes)
                    {
                        while (reader.MoveToNextAttribute())
                            writer.WriteAttributeString(reader.Prefix, reader.Name, reader.NamespaceURI, reader.Value);

                        reader.MoveToElement();
                    }

                    if (reader.LocalName == "SceneObjectPart")
                    {
                        if (sopDepth < 0)
                        {
                            sopDepth = reader.Depth;
//                            m_log.DebugFormat("[HG ASSET MAPPER]: Set sopDepth to {0}", sopDepth);
                        }
                    }
                    else
                    {
                        if (sopDepth >= 0 && reader.Depth == sopDepth + 1)
                        {
                            if (reader.Name == "CreatorID")
                            {
                                reader.Read();
                                if (reader.NodeType == XmlNodeType.Element && reader.Name == "Guid" || reader.Name == "UUID")
                                {
                                    reader.Read();

                                    if (reader.NodeType == XmlNodeType.Text)
                                    {
                                        UUID uuid = UUID.Zero;
                                        UUID.TryParse(reader.Value, out uuid);
                                        creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid);
                                        writer.WriteElementString("UUID", reader.Value);
                                        reader.Read();
                                    }
                                    else
                                    {
                                        // If we unexpected run across mixed content in this node, still carry on
                                        // transforming the subtree (this replicates earlier behaviour).
                                        TransformXml(reader, writer);
                                    }
                                }
                                else
                                {
                                    // If we unexpected run across mixed content in this node, still carry on
                                    // transforming the subtree (this replicates earlier behaviour).
                                    TransformXml(reader, writer);
                                }
                            }
                            else if (reader.Name == "CreatorData")
                            {
                                reader.Read();
                                if (reader.NodeType == XmlNodeType.Text)
                                {
                                    hasCreatorData = true;
                                    writer.WriteString(reader.Value);
                                }
                                else
                                {
                                    // If we unexpected run across mixed content in this node, still carry on
                                    // transforming the subtree (this replicates earlier behaviour).
                                    TransformXml(reader, writer);
                                }
                            }
                        }
                    }
                                        
                    if (reader.IsEmptyElement)
                    {
//                        m_log.DebugFormat("[HG ASSET MAPPER]: Writing end for empty element {0}", reader.Name);
                        writer.WriteEndElement();
                    }

                    break;

                    case XmlNodeType.EndElement:
//                    m_log.DebugFormat("Depth {0} at EndElement", reader.Depth);
                    if (sopDepth == reader.Depth)
                    {
                        if (!hasCreatorData && creator != null)
                            writer.WriteElementString(reader.Prefix, "CreatorData", reader.NamespaceURI, string.Format("{0};{1} {2}", m_HomeURI, creator.FirstName, creator.LastName));

//                        m_log.DebugFormat("[HG ASSET MAPPER]: Reset sopDepth");
                        sopDepth = -1;
                        creator = null;
                        hasCreatorData = false;
                    }
                    writer.WriteEndElement();
                    break;

                    case XmlNodeType.EntityReference:
                    writer.WriteEntityRef(reader.Name);
                    break;

                    case XmlNodeType.ProcessingInstruction:
                    writer.WriteProcessingInstruction(reader.Name, reader.Value);
                    break;

                    case XmlNodeType.Text:
                    writer.WriteString(reader.Value);
                    break;

                    case XmlNodeType.XmlDeclaration:
                    // For various reasons, not all serializations have xml declarations (or consistent ones) 
                    // and as it's embedded inside a byte stream we don't need it anyway, so ignore.
                    break;

                    default:
                    m_log.WarnFormat(
                        "[HG ASSET MAPPER]: Unrecognized node {0} in asset XML transform in {1}", 
                        reader.NodeType, m_scene.Name);
                    break;
                }
            }
        }
Exemple #23
0
        // From http://blogs.msdn.com/b/mfussell/archive/2005/02/12/371546.aspx
        static void WriteShallowNode( XmlReader reader, XmlWriter writer )
        {
            if ( reader == null )
            {
                throw new ArgumentNullException("reader");
            }
            if ( writer == null )
            {
                throw new ArgumentNullException("writer");
            }

            switch ( reader.NodeType )
            {
            case XmlNodeType.Element:
                writer.WriteStartElement( reader.Prefix, reader.LocalName, reader.NamespaceURI );
                writer.WriteAttributes( reader, true );
                if ( reader.IsEmptyElement )
                {
                    writer.WriteEndElement();
                }
                break;
            case XmlNodeType.Text:
                writer.WriteString( reader.Value );
                break;
            case XmlNodeType.Whitespace:
            case XmlNodeType.SignificantWhitespace:
                writer.WriteWhitespace(reader.Value);
                break;
            case XmlNodeType.CDATA:
                writer.WriteCData( reader.Value );
                break;
            case XmlNodeType.EntityReference:
                writer.WriteEntityRef(reader.Name);
                break;
            case XmlNodeType.XmlDeclaration:
            case XmlNodeType.ProcessingInstruction:
                writer.WriteProcessingInstruction( reader.Name, reader.Value );
                break;
            case XmlNodeType.DocumentType:
                writer.WriteDocType( reader.Name, reader.GetAttribute( "PUBLIC" ), reader.GetAttribute( "SYSTEM" ), reader.Value );
                break;
            case XmlNodeType.Comment:
                writer.WriteComment( reader.Value );
                break;
            case XmlNodeType.EndElement:
                writer.WriteFullEndElement();
                break;
            }
        }
Exemple #24
0
        public void EventsToWriter(XmlWriter writer)
        {
            if (this.singleText.Count != 0)
            {
                writer.WriteString(this.singleText.GetResult());
            }
            else
            {
                XmlRawWriter writer2 = writer as XmlRawWriter;
                for (int i = 0; i < this.pages.Count; i++)
                {
                    XmlEvent[] eventArray = this.pages[i];
                    for (int j = 0; j < eventArray.Length; j++)
                    {
                        byte[] buffer;
                        switch (eventArray[j].EventType)
                        {
                        case XmlEventType.Unknown:
                            return;

                        case XmlEventType.DocType:
                        {
                            writer.WriteDocType(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3, (string)eventArray[j].Object);
                            continue;
                        }

                        case XmlEventType.StartElem:
                        {
                            writer.WriteStartElement(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3);
                            continue;
                        }

                        case XmlEventType.StartAttr:
                        {
                            writer.WriteStartAttribute(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3);
                            continue;
                        }

                        case XmlEventType.EndAttr:
                        {
                            writer.WriteEndAttribute();
                            continue;
                        }

                        case XmlEventType.CData:
                        {
                            writer.WriteCData(eventArray[j].String1);
                            continue;
                        }

                        case XmlEventType.Comment:
                        {
                            writer.WriteComment(eventArray[j].String1);
                            continue;
                        }

                        case XmlEventType.PI:
                        {
                            writer.WriteProcessingInstruction(eventArray[j].String1, eventArray[j].String2);
                            continue;
                        }

                        case XmlEventType.Whitespace:
                        {
                            writer.WriteWhitespace(eventArray[j].String1);
                            continue;
                        }

                        case XmlEventType.String:
                        {
                            writer.WriteString(eventArray[j].String1);
                            continue;
                        }

                        case XmlEventType.Raw:
                        {
                            writer.WriteRaw(eventArray[j].String1);
                            continue;
                        }

                        case XmlEventType.EntRef:
                        {
                            writer.WriteEntityRef(eventArray[j].String1);
                            continue;
                        }

                        case XmlEventType.CharEnt:
                        {
                            writer.WriteCharEntity((char)eventArray[j].Object);
                            continue;
                        }

                        case XmlEventType.SurrCharEnt:
                        {
                            char[] chArray = (char[])eventArray[j].Object;
                            writer.WriteSurrogateCharEntity(chArray[0], chArray[1]);
                            continue;
                        }

                        case XmlEventType.Base64:
                        {
                            buffer = (byte[])eventArray[j].Object;
                            writer.WriteBase64(buffer, 0, buffer.Length);
                            continue;
                        }

                        case XmlEventType.BinHex:
                        {
                            buffer = (byte[])eventArray[j].Object;
                            writer.WriteBinHex(buffer, 0, buffer.Length);
                            continue;
                        }

                        case XmlEventType.XmlDecl1:
                        {
                            if (writer2 != null)
                            {
                                writer2.WriteXmlDeclaration((XmlStandalone)eventArray[j].Object);
                            }
                            continue;
                        }

                        case XmlEventType.XmlDecl2:
                        {
                            if (writer2 != null)
                            {
                                writer2.WriteXmlDeclaration(eventArray[j].String1);
                            }
                            continue;
                        }

                        case XmlEventType.StartContent:
                        {
                            if (writer2 != null)
                            {
                                writer2.StartElementContent();
                            }
                            continue;
                        }

                        case XmlEventType.EndElem:
                        {
                            if (writer2 == null)
                            {
                                break;
                            }
                            writer2.WriteEndElement(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3);
                            continue;
                        }

                        case XmlEventType.FullEndElem:
                        {
                            if (writer2 == null)
                            {
                                goto Label_0367;
                            }
                            writer2.WriteFullEndElement(eventArray[j].String1, eventArray[j].String2, eventArray[j].String3);
                            continue;
                        }

                        case XmlEventType.Nmsp:
                        {
                            if (writer2 == null)
                            {
                                goto Label_0394;
                            }
                            writer2.WriteNamespaceDeclaration(eventArray[j].String1, eventArray[j].String2);
                            continue;
                        }

                        case XmlEventType.EndBase64:
                        {
                            if (writer2 != null)
                            {
                                writer2.WriteEndBase64();
                            }
                            continue;
                        }

                        case XmlEventType.Close:
                        {
                            writer.Close();
                            continue;
                        }

                        case XmlEventType.Flush:
                        {
                            writer.Flush();
                            continue;
                        }

                        case XmlEventType.Dispose:
                        {
                            writer.Dispose();
                            continue;
                        }

                        default:
                        {
                            continue;
                        }
                        }
                        writer.WriteEndElement();
                        continue;
Label_0367:
                        writer.WriteFullEndElement();
                        continue;
Label_0394:
                        writer.WriteAttributeString("xmlns", eventArray[j].String1, "http://www.w3.org/2000/xmlns/", eventArray[j].String2);
                    }
                }
            }
        }
 public override void WriteTo(XmlWriter w)
 {
     w.WriteDocType(this.name, this.publicId, this.systemId, this.internalSubset);
 }
Exemple #26
0
 public static void WriteHtmlDeclaration(XmlWriter Writer, String PublicIdentifier = "-//W3C//DTD XHTML 1.0 Transitional//EN", String SystemIdentifier = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd")
 {
     Writer.WriteDocType("html", PublicIdentifier, SystemIdentifier, null);
 }
Exemple #27
0
        /// <summary>
        /// Replay all cached events to an XmlWriter.
        /// </summary>
        public void EventsToWriter(XmlWriter writer)
        {
            XmlEvent[] page;
            int        idxPage, idxEvent;

            byte[]       bytes;
            char[]       chars;
            XmlRawWriter rawWriter;

            // Special-case single text node at the top-level
            if (this.singleText.Count != 0)
            {
                writer.WriteString(this.singleText.GetResult());
                return;
            }

            rawWriter = writer as XmlRawWriter;

            // Loop over set of pages
            for (idxPage = 0; idxPage < this.pages.Count; idxPage++)
            {
                page = this.pages[idxPage];

                // Loop over events in each page
                for (idxEvent = 0; idxEvent < page.Length; idxEvent++)
                {
                    switch (page[idxEvent].EventType)
                    {
                    case XmlEventType.Unknown:
                        // No more events
                        Debug.Assert(idxPage + 1 == this.pages.Count);
                        return;

                    case XmlEventType.DocType:
                        writer.WriteDocType(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3, (string)page[idxEvent].Object);
                        break;

                    case XmlEventType.StartElem:
                        writer.WriteStartElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                        break;

                    case XmlEventType.StartAttr:
                        writer.WriteStartAttribute(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                        break;

                    case XmlEventType.EndAttr:
                        writer.WriteEndAttribute();
                        break;

                    case XmlEventType.CData:
                        writer.WriteCData(page[idxEvent].String1);
                        break;

                    case XmlEventType.Comment:
                        writer.WriteComment(page[idxEvent].String1);
                        break;

                    case XmlEventType.PI:
                        writer.WriteProcessingInstruction(page[idxEvent].String1, page[idxEvent].String2);
                        break;

                    case XmlEventType.Whitespace:
                        writer.WriteWhitespace(page[idxEvent].String1);
                        break;

                    case XmlEventType.String:
                        writer.WriteString(page[idxEvent].String1);
                        break;

                    case XmlEventType.Raw:
                        writer.WriteRaw(page[idxEvent].String1);
                        break;

                    case XmlEventType.EntRef:
                        writer.WriteEntityRef(page[idxEvent].String1);
                        break;

                    case XmlEventType.CharEnt:
                        writer.WriteCharEntity((char)page[idxEvent].Object);
                        break;

                    case XmlEventType.SurrCharEnt:
                        chars = (char[])page[idxEvent].Object;
                        writer.WriteSurrogateCharEntity(chars[0], chars[1]);
                        break;

                    case XmlEventType.Base64:
                        bytes = (byte[])page[idxEvent].Object;
                        writer.WriteBase64(bytes, 0, bytes.Length);
                        break;

                    case XmlEventType.BinHex:
                        bytes = (byte[])page[idxEvent].Object;
                        writer.WriteBinHex(bytes, 0, bytes.Length);
                        break;

                    case XmlEventType.XmlDecl1:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteXmlDeclaration((XmlStandalone)page[idxEvent].Object);
                        }
                        break;

                    case XmlEventType.XmlDecl2:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteXmlDeclaration(page[idxEvent].String1);
                        }
                        break;

                    case XmlEventType.StartContent:
                        if (rawWriter != null)
                        {
                            rawWriter.StartElementContent();
                        }
                        break;

                    case XmlEventType.EndElem:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                        }
                        else
                        {
                            writer.WriteEndElement();
                        }
                        break;

                    case XmlEventType.FullEndElem:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteFullEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                        }
                        else
                        {
                            writer.WriteFullEndElement();
                        }
                        break;

                    case XmlEventType.Nmsp:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteNamespaceDeclaration(page[idxEvent].String1, page[idxEvent].String2);
                        }
                        else
                        {
                            writer.WriteAttributeString("xmlns", page[idxEvent].String1, XmlReservedNs.NsXmlNs, page[idxEvent].String2);
                        }
                        break;

                    case XmlEventType.EndBase64:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteEndBase64();
                        }
                        break;

                    case XmlEventType.Close:
                        writer.Close();
                        break;

                    case XmlEventType.Flush:
                        writer.Flush();
                        break;

                    case XmlEventType.Dispose:
                        ((IDisposable)writer).Dispose();
                        break;

                    default:
                        Debug.Assert(false, "Unknown event: " + page[idxEvent].EventType);
                        break;
                    }
                }
            }

            Debug.Assert(false, "Unknown event should be added to end of event sequence.");
        }
Exemple #28
0
 public void WriteServiceExceptionReportDocType(XmlWriter writer)
 {
     if (Version > WmsVersionEnum.Version_1_0_7 && Version < WmsVersionEnum.Version_1_3_0)
     {
         writer.WriteDocType("ServiceExceptionReport", null, System(Version, "exception"), null);
     }
 }
Exemple #29
0
        //copies from example
        private void PassNodeThrough(XmlReader reader, XmlWriter writer)
        {
            switch (reader.NodeType)
            {
                case XmlNodeType.Element:
                    writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                    writer.WriteAttributes(reader, true);
                    if (reader.IsEmptyElement)
                    {
                        writer.WriteEndElement();
                    }
                    break;

                case XmlNodeType.Text:
                    writer.WriteString(reader.Value);
                    break;

                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    writer.WriteWhitespace(reader.Value);
                    break;

                case XmlNodeType.CDATA:
                    writer.WriteCData(reader.Value);
                    break;

                case XmlNodeType.EntityReference:
                    writer.WriteEntityRef(reader.Name);
                    break;

                case XmlNodeType.XmlDeclaration:
                case XmlNodeType.ProcessingInstruction:
                    writer.WriteProcessingInstruction(reader.Name, reader.Value);
                    break;

                case XmlNodeType.DocumentType:
                    writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
                    break;

                case XmlNodeType.Comment:
                    writer.WriteComment(reader.Value);
                    break;

                case XmlNodeType.EndElement:
                    writer.WriteFullEndElement();
                    break;
            }
        }
        // Writes the content (inner XML) of the current node into the provided XmlWriter.
        private void WriteNode(XmlWriter xtw, bool defattr) {
#if !SILVERLIGHT
            Debug.Assert(xtw is XmlTextWriter);
#endif
            int d = this.NodeType == XmlNodeType.None ? -1 : this.Depth;
            while (this.Read() && (d < this.Depth)) {
                switch (this.NodeType) {
                    case XmlNodeType.Element:
                        xtw.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI);
#if !SILVERLIGHT // Removing dependency on XmlTextWriter
                        ((XmlTextWriter)xtw).QuoteChar = this.QuoteChar;
#endif
                        xtw.WriteAttributes(this, defattr);
                        if (this.IsEmptyElement) {
                            xtw.WriteEndElement();
                        }
                        break;
                    case XmlNodeType.Text:
                        xtw.WriteString(this.Value);
                        break;
                    case XmlNodeType.Whitespace:
                    case XmlNodeType.SignificantWhitespace:
                        xtw.WriteWhitespace(this.Value);
                        break;
                    case XmlNodeType.CDATA:
                        xtw.WriteCData(this.Value);
                        break;
                    case XmlNodeType.EntityReference:
                        xtw.WriteEntityRef(this.Name);
                        break;
                    case XmlNodeType.XmlDeclaration:
                    case XmlNodeType.ProcessingInstruction:
                        xtw.WriteProcessingInstruction(this.Name, this.Value);
                        break;
                    case XmlNodeType.DocumentType:
                        xtw.WriteDocType(this.Name, this.GetAttribute("PUBLIC"), this.GetAttribute("SYSTEM"), this.Value);
                        break;
                    case XmlNodeType.Comment:
                        xtw.WriteComment(this.Value);
                        break;
                    case XmlNodeType.EndElement:
                        xtw.WriteFullEndElement();
                        break;
                }
            }
            if (d == this.Depth && this.NodeType == XmlNodeType.EndElement) {
                Read();
            }
        }
 /// <summary>Saves the node to the specified <see cref="T:System.Xml.XmlWriter" />.</summary>
 /// <param name="w">The XmlWriter to which you want to save. </param>
 public override void WriteTo(XmlWriter w)
 {
     w.WriteDocType(this.Name, this.PublicId, this.SystemId, this.InternalSubset);
 }
        /// <summary>
        /// Preprocesses and copies an Xml document from a reader into a writer.
        /// </summary>
        /// <param name="xmlReader">The Xml reader.</param>
        /// <param name="xmlWriter">The Xml writer.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="xmlReader"/>
        /// or <paramref name="xmlWriter"/> is null.</exception>
        /// <exception cref="InvalidOperationException">Thrown if the input Xml is malformed
        /// such as if it contains unbalanced ifdef/endif pairs.</exception>
        public void Preprocess(XmlReader xmlReader, XmlWriter xmlWriter)
        {
            if (xmlReader == null)
                throw new ArgumentNullException("xmlReader");
            if (xmlWriter == null)
                throw new ArgumentNullException("xmlWriter");

            // Tracks whether a given block has been included or excluded.
            Stack<bool> blockStack = new Stack<bool>();
            blockStack.Push(true);

            while (xmlReader.Read())
            {
                if (xmlReader.NodeType == XmlNodeType.ProcessingInstruction)
                {
                    switch (xmlReader.Name)
                    {
                        case "define":
                            if (blockStack.Peek())
                                Define(xmlReader.Value.Trim());
                            continue;

                        case "ifdef":
                            blockStack.Push(blockStack.Peek() && IsDefined(xmlReader.Value.Trim()));
                            continue;

                        case "ifndef":
                            blockStack.Push(blockStack.Peek() && !IsDefined(xmlReader.Value.Trim()));
                            continue;

                        case "else":
                            if (blockStack.Count == 1)
                                throw new InvalidOperationException(
                                    "Found <?else?> instruction without enclosing <?ifdef?> or <?ifndef?> block.");
                            blockStack.Push(!blockStack.Pop() && blockStack.Peek()); // order matters
                            continue;

                        case "endif":
                            if (blockStack.Count == 1)
                                throw new InvalidOperationException(
                                    "Found <?endif?> instruction without matching <?ifdef?> or <?ifndef?>.");
                            blockStack.Pop();
                            continue;
                    }
                }

                if (!blockStack.Peek())
                    continue;

                switch (xmlReader.NodeType)
                {
                    case XmlNodeType.Element:
                        xmlWriter.WriteStartElement(xmlReader.Prefix, xmlReader.LocalName, xmlReader.NamespaceURI);
                        xmlWriter.WriteAttributes(xmlReader, true);
                        if (xmlReader.IsEmptyElement)
                            xmlWriter.WriteEndElement();
                        break;

                    case XmlNodeType.Text:
                        xmlWriter.WriteValue(xmlReader.Value);
                        break;

                    case XmlNodeType.CDATA:
                        xmlWriter.WriteCData(xmlReader.Value);
                        break;

                    case XmlNodeType.EntityReference:
                        xmlWriter.WriteEntityRef(xmlReader.Name);
                        break;

                    case XmlNodeType.Comment:
                        xmlWriter.WriteComment(xmlReader.Value);
                        break;

                    case XmlNodeType.DocumentType:
                        xmlWriter.WriteDocType(xmlReader.Name, xmlReader.GetAttribute("PUBLIC"),
                            xmlReader.GetAttribute("SYSTEM"), xmlReader.Value);
                        break;

                    case XmlNodeType.Whitespace:
                    case XmlNodeType.SignificantWhitespace:
                        xmlWriter.WriteWhitespace(xmlReader.Value);
                        break;

                    case XmlNodeType.EndElement:
                        xmlWriter.WriteFullEndElement();
                        break;

                    case XmlNodeType.XmlDeclaration:
                    case XmlNodeType.ProcessingInstruction:
                        xmlWriter.WriteProcessingInstruction(xmlReader.Name, xmlReader.Value);
                        break;
                }
            }

            if (blockStack.Count != 1)
                throw new InvalidOperationException("Missing <?endif?> instruction.");

            xmlWriter.Flush();
        }
Exemple #33
0
 public override void WriteDocType(string name, string pubid, string sysid, string subset)
 {
     writer.WriteDocType(name, pubid, sysid, subset);
     state = WriteState.Prolog;
 }
Exemple #34
0
        /* -------------------------------------------------------------------------------------
        * Name:  WriteShallowNode
        * Goal:  Copy piece-by-piece
        * History:
        * 2/oct/2015 ERK Created
          ------------------------------------------------------------------------------------- */
        public void WriteShallowNode(XmlReader reader, XmlWriter writer)
        {
            if (reader == null) {
            throw new ArgumentNullException("reader");
              }
              if (writer == null) {
            throw new ArgumentNullException("writer");
              }
              try {
            switch (reader.NodeType) {
              case XmlNodeType.Element:
            writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
            bool bIsFOLIA = (reader.LocalName == "FoLiA");
            string sLocalName = reader.LocalName;
            // Process attributes one by one
            if (reader.HasAttributes) {
              if (reader.MoveToFirstAttribute()) {
                do {
                  if (reader.Name != "xmlns") {
                    bool bWritten = false;
                    // Action depends on local name
                    switch (sLocalName) {
                      case "FoLiA":
                        // Is the the attribute @version?
                        if (reader.Name == "version") { writer.WriteAttributeString(reader.Name, FOLIA_VERSION); bWritten = true; }
                        break;
                      case "t":
                        // is this the attribute @class?
                        if (reader.Name == "class") { writer.WriteAttributeString(reader.Name, "eng"); bWritten = true; }
                        break;
                    }
                    if (!bWritten) {
                      String[] arName = reader.Name.Split(':');
                      if (arName.Length > 1) {
                        writer.WriteAttributeString(arName[0], arName[1], null, reader.Value);

                      } else {
                        writer.WriteAttributeString(reader.Name, reader.Value);
                      }
                    }
                    /*
                    // Check for FoLiA version
                    if (bIsFOLIA && reader.Name == "version") {
                      // Adapt version number
                      writer.WriteAttributeString(reader.Name, FOLIA_VERSION);
                    } else {
                      String[] arName = reader.Name.Split(':');
                      if (arName.Length > 1) {
                        writer.WriteAttributeString(arName[0], arName[1], null, reader.Value);

                      } else {
                        writer.WriteAttributeString(reader.Name, reader.Value);
                      }
                    } */
                  }
                } while (reader.MoveToNextAttribute());
              }
            }

            if (reader.IsEmptyElement) {
              writer.WriteEndElement();
            }
            break;
              case XmlNodeType.Text:
            writer.WriteString(reader.Value);
            break;
              case XmlNodeType.Whitespace:
              case XmlNodeType.SignificantWhitespace:
            writer.WriteWhitespace(reader.Value);
            break;
              case XmlNodeType.CDATA:
            writer.WriteCData(reader.Value);
            break;
              case XmlNodeType.EntityReference:
            writer.WriteEntityRef(reader.Name);
            break;
              case XmlNodeType.XmlDeclaration:
              case XmlNodeType.ProcessingInstruction:
            writer.WriteProcessingInstruction(reader.Name, reader.Value);
            break;
              case XmlNodeType.DocumentType:
            writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
            break;
              case XmlNodeType.Comment:
            writer.WriteComment(reader.Value);
            break;
              case XmlNodeType.EndElement:
            writer.WriteFullEndElement();
            break;
            }
              } catch (Exception ex) {
            errHandle.DoError("WriteShallowNode", ex); // Provide standard error message
              }
        }
Exemple #35
0
        public static void WriteShallowNode(XmlReader reader, XmlWriter writer)
        {
            //Console.WriteLine("{0}: {1}", reader.NodeType, reader.Name);

            switch(reader.NodeType) {
                case XmlNodeType.Element:
                    writer.WriteStartElement(reader.Prefix	, reader.LocalName, reader.NamespaceURI);
                    writer.WriteAttributes(reader, true);
                    if(reader.IsEmptyElement)
                        writer.WriteEndElement();
                    break;
                case XmlNodeType.Text:
                    writer.WriteString(reader.Value);
                    break;
                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    writer.WriteWhitespace(reader.Value);
                    break;
                case XmlNodeType.CDATA:
                    writer.WriteCData(reader.Value);
                    break;
                case XmlNodeType.EntityReference:
                    writer.WriteEntityRef(reader.Name);
                    break;
                case XmlNodeType.XmlDeclaration:
                case XmlNodeType.ProcessingInstruction:
                    writer.WriteProcessingInstruction(reader.Name, reader.Value);
                    break;
                case XmlNodeType.DocumentType:
                    writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
                    break;
                case XmlNodeType.Comment:
                    writer.WriteComment(reader.Value);
                    break;
                case XmlNodeType.EndElement:
                    writer.WriteFullEndElement();
                    break;
            }
        }
 public override void WriteDocType(string name, string pubid, string sysid, string subset)
 {
     writer.WriteDocType(name, pubid, sysid, subset);
 }
 public override void WriteTo(XmlWriter writer)
 {
     XDocument doc = Document;
     XElement root = doc.Root;
     if (root != null)
         writer.WriteDocType (root.Name.LocalName, pubid, sysid, intSubset);
 }
Exemple #38
0
 /// <include file='doc\XmlDocumentType.uex' path='docs/doc[@for="XmlDocumentType.WriteTo"]/*' />
 /// <devdoc>
 ///    <para>Saves the node to the specified XmlWriter.</para>
 /// </devdoc>
 public override void WriteTo(XmlWriter w) {
     w.WriteDocType( name, publicId, systemId, internalSubset );
 }
Exemple #39
0
		public override void WriteTo (XmlWriter w)
		{
			w.WriteDocType (Name, PublicId, SystemId, InternalSubset);
		}
        private void WriteNode(XmlWriter xtw, bool defattr)
        {
            int num = (this.NodeType == XmlNodeType.None) ? -1 : this.Depth;
            while (this.Read() && (num < this.Depth))
            {
                switch (this.NodeType)
                {
                    case XmlNodeType.Element:
                        xtw.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI);
                        ((XmlTextWriter) xtw).QuoteChar = this.QuoteChar;
                        xtw.WriteAttributes(this, defattr);
                        if (this.IsEmptyElement)
                        {
                            xtw.WriteEndElement();
                        }
                        break;

                    case XmlNodeType.Text:
                        xtw.WriteString(this.Value);
                        break;

                    case XmlNodeType.CDATA:
                        xtw.WriteCData(this.Value);
                        break;

                    case XmlNodeType.EntityReference:
                        xtw.WriteEntityRef(this.Name);
                        break;

                    case XmlNodeType.ProcessingInstruction:
                    case XmlNodeType.XmlDeclaration:
                        xtw.WriteProcessingInstruction(this.Name, this.Value);
                        break;

                    case XmlNodeType.Comment:
                        xtw.WriteComment(this.Value);
                        break;

                    case XmlNodeType.DocumentType:
                        xtw.WriteDocType(this.Name, this.GetAttribute("PUBLIC"), this.GetAttribute("SYSTEM"), this.Value);
                        break;

                    case XmlNodeType.Whitespace:
                    case XmlNodeType.SignificantWhitespace:
                        xtw.WriteWhitespace(this.Value);
                        break;

                    case XmlNodeType.EndElement:
                        xtw.WriteFullEndElement();
                        break;
                }
            }
            if ((num == this.Depth) && (this.NodeType == XmlNodeType.EndElement))
            {
                this.Read();
            }
        }
 // Writes the content (inner XML) of the current node into the provided XmlWriter.
 private async Task WriteNodeAsync(XmlWriter xtw, bool defattr)
 {
     int d = this.NodeType == XmlNodeType.None ? -1 : this.Depth;
     while (await this.ReadAsync().ConfigureAwait(false) && (d < this.Depth))
     {
         switch (this.NodeType)
         {
             case XmlNodeType.Element:
                 xtw.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI);
                 xtw.WriteAttributes(this, defattr);
                 if (this.IsEmptyElement)
                 {
                     xtw.WriteEndElement();
                 }
                 break;
             case XmlNodeType.Text:
                 xtw.WriteString(await this.GetValueAsync().ConfigureAwait(false));
                 break;
             case XmlNodeType.Whitespace:
             case XmlNodeType.SignificantWhitespace:
                 xtw.WriteWhitespace(await this.GetValueAsync().ConfigureAwait(false));
                 break;
             case XmlNodeType.CDATA:
                 xtw.WriteCData(this.Value);
                 break;
             case XmlNodeType.EntityReference:
                 xtw.WriteEntityRef(this.Name);
                 break;
             case XmlNodeType.XmlDeclaration:
             case XmlNodeType.ProcessingInstruction:
                 xtw.WriteProcessingInstruction(this.Name, this.Value);
                 break;
             case XmlNodeType.DocumentType:
                 xtw.WriteDocType(this.Name, this.GetAttribute("PUBLIC"), this.GetAttribute("SYSTEM"), this.Value);
                 break;
             case XmlNodeType.Comment:
                 xtw.WriteComment(this.Value);
                 break;
             case XmlNodeType.EndElement:
                 xtw.WriteFullEndElement();
                 break;
         }
     }
     if (d == this.Depth && this.NodeType == XmlNodeType.EndElement)
     {
         await ReadAsync().ConfigureAwait(false);
     }
 }