X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.XML%2FMono.Xml%2FXmlNodeWriter.cs;h=49ada453ab67fce89e83a351093bc674be9e2573;hb=f0c4bb76e4ecda59938fa6d2fde07b84e322b14e;hp=4caebe0da0ce27886a4a545c2c907db7ec058fe0;hpb=fb2d0d5f7110caca29de57ae93c3d99400097e8c;p=mono.git diff --git a/mcs/class/System.XML/Mono.Xml/XmlNodeWriter.cs b/mcs/class/System.XML/Mono.Xml/XmlNodeWriter.cs index 4caebe0da0c..49ada453ab6 100644 --- a/mcs/class/System.XML/Mono.Xml/XmlNodeWriter.cs +++ b/mcs/class/System.XML/Mono.Xml/XmlNodeWriter.cs @@ -6,24 +6,45 @@ // // (C)2003 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.Xml; -namespace Mono.Xml +namespace System.Xml { - public class XmlNodeWriter : XmlWriter + internal class XmlNodeWriter : XmlWriter { public XmlNodeWriter () : this (true) { } // It should be public after some tests are done :-) - private XmlNodeWriter (bool isDocumentEntity) + public XmlNodeWriter (bool isDocumentEntity) { doc = new XmlDocument (); state = XmlNodeType.None; this.isDocumentEntity = isDocumentEntity; - if (isDocumentEntity) + if (!isDocumentEntity) current = fragment = doc.CreateDocumentFragment (); } @@ -46,7 +67,7 @@ namespace Mono.Xml // Properties public XmlNode Document { - get { return isDocumentEntity ? (XmlNode)fragment : (XmlNode)doc; } + get { return isDocumentEntity ? (XmlNode)doc : (XmlNode)fragment; } } public override WriteState WriteState { @@ -113,7 +134,7 @@ namespace Mono.Xml throw new InvalidOperationException (String.Format ("Current state is not acceptable for {0}.", n.NodeType)); if (state != XmlNodeType.Element) - doc.AppendChild (n); + Document.AppendChild (n); else if (attribute != null) attribute.AppendChild (n); else @@ -198,7 +219,7 @@ namespace Mono.Xml XmlElement el = doc.CreateElement (prefix, name, ns); if (current == null) { - doc.AppendChild (el); + Document.AppendChild (el); state = XmlNodeType.Element; } else { current.AppendChild (el); @@ -229,10 +250,10 @@ namespace Mono.Xml if (!forceFull && current.FirstChild == null) ((XmlElement) current).IsEmpty = true; - if (current.ParentNode == doc) + if (isDocumentEntity && current.ParentNode == doc) state = XmlNodeType.EndElement; else - current = current.ParentNode as XmlElement; + current = current.ParentNode; } // StartAttribute