diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2003-01-18 14:30:12 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2003-01-18 14:30:12 +0300 |
commit | 2d7a230c66956b5c1d582513201054c1f4659650 (patch) | |
tree | e7da1b0c95ee294c152f85910ee2035c6f0c105c /mcs/class/System.XML/System.Xml/XmlWriter.cs | |
parent | 346f3b40cf45d1ae0d70cf5a8082829a9ba03682 (diff) |
2003-01-18 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XmlWriter.cs: modified WriteStartElement (see test for detail).
Added WriteNode.
svn path=/trunk/mcs/; revision=10654
Diffstat (limited to 'mcs/class/System.XML/System.Xml/XmlWriter.cs')
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlWriter.cs | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/mcs/class/System.XML/System.Xml/XmlWriter.cs b/mcs/class/System.XML/System.Xml/XmlWriter.cs index 29050c5f315..c7d4bbd330e 100644 --- a/mcs/class/System.XML/System.Xml/XmlWriter.cs +++ b/mcs/class/System.XML/System.Xml/XmlWriter.cs @@ -159,10 +159,61 @@ namespace System.Xml public abstract void WriteNmToken (string name); - [MonoTODO] + [MonoTODO("needs to test")] public virtual void WriteNode (XmlReader reader, bool defattr) { - throw new NotImplementedException (); + if (reader == null) + throw new ArgumentException (); + + if (reader.ReadState == ReadState.Initial) { + while (reader.Read ()) + WriteNode (reader, defattr); + } + else { + switch (reader.NodeType) { + case XmlNodeType.Element: + WriteStartElement (reader.Prefix, reader.LocalName, reader.NamespaceURI); + WriteAttributes (reader, defattr); + if (reader.IsEmptyElement) + WriteEndElement (); + break; + case XmlNodeType.Attribute: + break; + case XmlNodeType.Text: + WriteString (reader.Value); + break; + case XmlNodeType.CDATA: + WriteCData (reader.Value); + break; + case XmlNodeType.EntityReference: + WriteEntityRef (reader.Name); + break; + case XmlNodeType.ProcessingInstruction: + WriteProcessingInstruction (reader.Name, reader.Value); + break; + case XmlNodeType.Comment: + WriteComment (reader.Value); + break; + case XmlNodeType.DocumentType: + WriteDocType (reader.Name, + reader ["PUBLIC"], reader ["SYSTEM"], reader.Value); + break; + case XmlNodeType.SignificantWhitespace: + goto case XmlNodeType.Whitespace; + case XmlNodeType.Whitespace: + WriteWhitespace (reader.Value); + break; + case XmlNodeType.EndElement: + break; + case XmlNodeType.EndEntity: + break; + case XmlNodeType.XmlDeclaration: + WriteStartDocument (reader.GetAttribute ("standalone").ToLower () == "yes"); + break; + default: + throw new NotImplementedException (); + } + } } public abstract void WriteProcessingInstruction (string name, string text); @@ -186,12 +237,12 @@ namespace System.Xml public void WriteStartElement (string localName) { - WriteStartElement (String.Empty, localName, String.Empty); + WriteStartElement (null, localName, null); } public void WriteStartElement (string localName, string ns) { - WriteStartElement (String.Empty, localName, ns); + WriteStartElement (null, localName, ns); } public abstract void WriteStartElement (string prefix, string localName, string ns); |