-//\r
-// System.Xml.XmlDocumentFragment\r
-//\r
-// Author:\r
-// Duncan Mak (duncan@ximian.com)\r
-// Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)\r
-//\r
-// (C), Ximian, Inc\r
-// (C)2002 Atsushi Enomoto\r
-\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-using System;\r
-using System.IO;\r
-using System.Text;\r
-using System.Xml.XPath;\r
-\r
-namespace System.Xml\r
-{\r
- public class XmlDocumentFragment : XmlNode\r
- {\r
-\r
- #region Constructor\r
-\r
- protected internal XmlDocumentFragment (XmlDocument doc)\r
- : base (doc)\r
- {\r
- }\r
- \r
- #endregion\r
-\r
- #region Properties\r
-\r
- public override string InnerXml {\r
- set {\r
- // Copied from XmlElement.InnerXml (in the meantime;-))\r
- for (int i = 0; i < ChildNodes.Count; i++)\r
- this.RemoveChild (ChildNodes [i]);\r
-\r
- // I hope there are any well-performance logic...\r
- XmlNamespaceManager nsmgr = this.ConstructNamespaceManager ();\r
- XmlParserContext ctx = new XmlParserContext (OwnerDocument.NameTable, nsmgr,\r
- OwnerDocument.DocumentType != null ? OwnerDocument.DocumentType.DTD : null,\r
- BaseURI, XmlLang, XmlSpace, null);\r
- XmlTextReader xmlReader = new XmlTextReader (value, XmlNodeType.Element, ctx);\r
- xmlReader.XmlResolver = OwnerDocument.Resolver;\r
-\r
- do {\r
- XmlNode n = OwnerDocument.ReadNode (xmlReader);\r
- if(n == null) break;\r
- AppendChild (n);\r
- } while (true);\r
- }\r
- get {\r
- StringBuilder sb = new StringBuilder ();\r
- for (int i = 0; i < ChildNodes.Count; i++)\r
- sb.Append (ChildNodes [i].OuterXml);\r
- return sb.ToString ();\r
- }\r
- }\r
- \r
- public override string LocalName {\r
- get { return "#document-fragment"; }\r
- }\r
-\r
-\r
- public override string Name { \r
- get { return "#document-fragment"; }\r
- }\r
-\r
- public override XmlNodeType NodeType {\r
- get { return XmlNodeType.DocumentFragment; }\r
- }\r
-\r
- public override XmlDocument OwnerDocument {\r
- get { return base.OwnerDocument; }\r
- }\r
-\r
- public override XmlNode ParentNode {\r
- get { return null; } // it's always null here.\r
- }\r
-\r
- internal override XPathNodeType XPathNodeType\r
- {\r
- get { return XPathNodeType.Root; }\r
- }\r
- #endregion\r
-\r
- #region Methods \r
- public override XmlNode CloneNode (bool deep)\r
- {\r
- if (deep) { // clone document + child nodes\r
- XmlNode node = FirstChild;\r
-\r
- while ((node != null) && (node.HasChildNodes)) {\r
- AppendChild (node.NextSibling.CloneNode (false));\r
- node = node.NextSibling;\r
- }\r
-\r
- return node;\r
- } else\r
- return new XmlDocumentFragment (OwnerDocument);\r
- }\r
-\r
- public override void WriteContentTo (XmlWriter w)\r
- {\r
- for (int i = 0; i < ChildNodes.Count; i++)\r
- ChildNodes [i].WriteContentTo (w);\r
- }\r
-\r
- public override void WriteTo (XmlWriter w)\r
- {\r
- for (int i = 0; i < ChildNodes.Count; i++)\r
- ChildNodes [i].WriteTo (w);\r
- }\r
-\r
- #endregion\r
- }\r
-}\r
+//
+// System.Xml.XmlDocumentFragment
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+// Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
+//
+// (C), Ximian, Inc
+// (C)2002 Atsushi Enomoto
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Text;
+using System.Xml.XPath;
+
+namespace System.Xml
+{
+ public class XmlDocumentFragment : XmlNode, IHasXmlChildNode
+ {
+ XmlLinkedNode lastLinkedChild;
+
+ #region Constructor
+
+ protected internal XmlDocumentFragment (XmlDocument doc)
+ : base (doc)
+ {
+ }
+
+ #endregion
+
+ #region Properties
+
+ XmlLinkedNode IHasXmlChildNode.LastLinkedChild {
+ get { return lastLinkedChild; }
+ set { lastLinkedChild = value; }
+ }
+
+ public override string InnerXml {
+ set {
+ // Copied from XmlElement.InnerXml (in the meantime;-))
+ for (int i = 0; i < ChildNodes.Count; i++)
+ this.RemoveChild (ChildNodes [i]);
+
+ // I hope there are any well-performance logic...
+ XmlNamespaceManager nsmgr = this.ConstructNamespaceManager ();
+ XmlParserContext ctx = new XmlParserContext (OwnerDocument.NameTable, nsmgr,
+ OwnerDocument.DocumentType != null ? OwnerDocument.DocumentType.DTD : null,
+ BaseURI, XmlLang, XmlSpace, null);
+ XmlTextReader xmlReader = new XmlTextReader (value, XmlNodeType.Element, ctx);
+ xmlReader.XmlResolver = OwnerDocument.Resolver;
+
+ do {
+ XmlNode n = OwnerDocument.ReadNode (xmlReader);
+ if(n == null) break;
+ AppendChild (n);
+ } while (true);
+ }
+ get {
+ StringBuilder sb = new StringBuilder ();
+ for (int i = 0; i < ChildNodes.Count; i++)
+ sb.Append (ChildNodes [i].OuterXml);
+ return sb.ToString ();
+ }
+ }
+
+ public override string LocalName {
+ get { return "#document-fragment"; }
+ }
+
+
+ public override string Name {
+ get { return "#document-fragment"; }
+ }
+
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.DocumentFragment; }
+ }
+
+ public override XmlDocument OwnerDocument {
+ get { return base.OwnerDocument; }
+ }
+
+ public override XmlNode ParentNode {
+ get { return null; } // it's always null here.
+ }
+
+ internal override XPathNodeType XPathNodeType
+ {
+ get { return XPathNodeType.Root; }
+ }
+ #endregion
+
+ #region Methods
+ public override XmlNode CloneNode (bool deep)
+ {
+ if (deep) { // clone document + child nodes
+ XmlNode node = FirstChild;
+
+ while ((node != null) && (node.HasChildNodes)) {
+ AppendChild (node.NextSibling.CloneNode (false));
+ node = node.NextSibling;
+ }
+
+ return node;
+ } else
+ return new XmlDocumentFragment (OwnerDocument);
+ }
+
+ public override void WriteContentTo (XmlWriter w)
+ {
+ for (int i = 0; i < ChildNodes.Count; i++)
+ ChildNodes [i].WriteContentTo (w);
+ }
+
+ public override void WriteTo (XmlWriter w)
+ {
+ for (int i = 0; i < ChildNodes.Count; i++)
+ ChildNodes [i].WriteTo (w);
+ }
+
+ #endregion
+ }
+}