+ // How to resolve default attribute values?
+ switch(node.NodeType)
+ {
+ case XmlNodeType.Attribute:
+ {
+ XmlAttribute src_att = node as XmlAttribute;
+ XmlAttribute dst_att = this.CreateAttribute(src_att.Prefix, src_att.LocalName, src_att.NamespaceURI);
+ // TODO: resolve default attribute values
+ dst_att.Value = src_att.Value;
+ return dst_att;
+ }
+
+ 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 = (XmlElement)node;
+ XmlElement dst = this.CreateElement(src.Prefix, src.LocalName, src.NamespaceURI);
+ foreach(XmlAttribute attr in src.Attributes)
+ {
+ // TODO: create default attribute values
+ dst.SetAttributeNode((XmlAttribute)this.ImportNode(attr, deep));
+ }
+ if(deep)
+ {
+ foreach(XmlNode n in src.ChildNodes)
+ dst.AppendChild(this.ImportNode(n, deep));
+ }
+ return dst;
+ }
+
+ case XmlNodeType.EndElement:
+ throw new XmlException ("Illegal ImportNode call for NodeType.EndElement");
+ case XmlNodeType.EndEntity:
+ throw new XmlException ("Illegal ImportNode call for NodeType.EndEntity");
+ case XmlNodeType.Entity:
+ throw new NotImplementedException ();
+
+ // [2002.10.14] CreateEntityReference not implemented.
+ case XmlNodeType.EntityReference:
+ throw new NotImplementedException("ImportNode of EntityReference not implemented mainly because CreateEntityReference was implemented in the meantime.");
+// return this.CreateEntityReference(node.Name);
+
+ case XmlNodeType.None:
+ throw new XmlException ("Illegal ImportNode call for NodeType.None");
+ 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);
+
+ // I don't know how to test it...
+ case XmlNodeType.XmlDeclaration:
+ // return this.CreateNode(XmlNodeType.XmlDeclaration, String.Empty, node.Value);
+ throw new NotImplementedException ();
+
+ default:
+ throw new NotImplementedException ();
+ }