diff options
author | Miguel de Icaza <miguel@gnome.org> | 2002-10-13 02:17:24 +0400 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2002-10-13 02:17:24 +0400 |
commit | 4f7b717a86279755502b95577a461d9092f490bd (patch) | |
tree | de057bd0fb31398e18e3b611572b89dff54c0b05 /mcs/class/System.XML/System.Xml | |
parent | 40f69d737943f485ddb5da7fa372bb07cfe88fc4 (diff) |
2002-10-12 A.Enomoto <ginga@kit.hi-ho.ne.jp>
* XmlDocument.cs (ImportNode): Implemented
svn path=/trunk/mcs/; revision=8205
Diffstat (limited to 'mcs/class/System.XML/System.Xml')
-rw-r--r-- | mcs/class/System.XML/System.Xml/ChangeLog | 4 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlDocument.cs | 74 |
2 files changed, 77 insertions, 1 deletions
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index 37b0db25b4c..925d3b35c0f 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,3 +1,7 @@ +2002-10-12 A.Enomoto <ginga@kit.hi-ho.ne.jp> + + * XmlDocument.cs (ImportNode): Implemented + 2002-10-06 Gonzalo Paniagua Javier <gonzalo@ximian.com> * XmlDocument.cs: one more Load method implemented. diff --git a/mcs/class/System.XML/System.Xml/XmlDocument.cs b/mcs/class/System.XML/System.Xml/XmlDocument.cs index 1187dec220c..03a2d42caf7 100644 --- a/mcs/class/System.XML/System.Xml/XmlDocument.cs +++ b/mcs/class/System.XML/System.Xml/XmlDocument.cs @@ -395,7 +395,79 @@ namespace System.Xml [MonoTODO] public virtual XmlNode ImportNode (XmlNode node, bool deep) { - throw new NotImplementedException (); + switch(node.NodeType) + { + case XmlNodeType.Attribute: + XmlAttribute a = node as XmlAttribute; + return this.CreateAttribute(a.Prefix, a.LocalName, a.NamespaceURI); + + case XmlNodeType.CDATA: + return this.CreateCDataSection(node.Value); + + case XmlNodeType.Comment: + return this.CreateComment(node.Value); + + case XmlNodeType.Document: + throw new XmlException("Document cannot be imported."); + + case XmlNodeType.DocumentFragment: + XmlDocumentFragment df = this.CreateDocumentFragment(); + if(deep) + { + foreach(XmlNode n in node.ChildNodes) + { + df.AppendChild(this.ImportNode(n, deep)); + } + } + return df; + + case XmlNodeType.DocumentType: + throw new XmlException("DocumentType cannot be imported."); + + case XmlNodeType.Element: + XmlElement src = node as XmlElement; + XmlElement dst = this.CreateElement(src.Prefix, src.LocalName, src.NamespaceURI); + if(deep) + { + foreach(XmlNode n in src.ChildNodes) + dst.AppendChild(this.ImportNode(n, deep)); + } + return dst; + + //case XmlNodeType.EndElement: + // throw new NotImplementedException (); + //case XmlNodeType.EndEntity: + // throw new NotImplementedException (); + //case XmlNodeType.Entity: + // throw new NotImplementedException (); + + case XmlNodeType.EntityReference: + return this.CreateEntityReference(node.Name); + + //case XmlNodeType.None: + // throw new NotImplementedException (); + //case XmlNodeType.Notation: + // throw new NotImplementedException (); + + case XmlNodeType.ProcessingInstruction: + XmlProcessingInstruction pi = node as XmlProcessingInstruction; + return this.CreateProcessingInstruction(pi.Target, pi.Data); + + case XmlNodeType.SignificantWhitespace: + return this.CreateSignificantWhitespace(node.Value); + + case XmlNodeType.Text: + return this.CreateTextNode(node.Value); + + case XmlNodeType.Whitespace: + return this.CreateWhitespace(node.Value); + + //case XmlNodeType.XmlDeclaration: + // throw new NotImplementedException (); + + default: + throw new NotImplementedException (); + } } public virtual void Load (Stream inStream) |