Files
mono/mcs/class/System.XML/System.Xml/XmlDocumentFragment.cs
T
Atsushi Eno 54cf27af0a 2003-08-08 Atsushi Enomoto <[email protected]>
* XmlInputStream.cs :
	  Fixed Initialize() that might result in incorrect buffer.
	  CanRead and Position should consider buffer (especially when the
	  stream was EOF).
	  CanSeek should use stream's CanSeek.

	* XmlChar.cs : added GetPredefinedEntity().
	* DTDObjectModel.cs :
	  - Modified ComputeDefaultValue() to use it.
	  - Fixed NormalizedDefaultValue not to expect parsed value as string.
	  - ResolveExternalEntity now detects invalid standalone specification.
	  - DTDParameterEntityDeclaration.Value is now changed to property and
	    keep its resolved value of literal value of external value using
	    new Resolve (XmlResolver) method (called only by XmlTextReader).
	* DTDValidatingReader.cs :
	  - It now handles entity-expanded Whitespace and SignificantWhitespace
	    correctly. Does not raise unexpected text not allowed error.
	  - Fixed MoveToAttribute()s to move internal reader correctly, and
	    should be able to move in other cases than on element node.
	  - On Read()ing document type and ResolveEntity(), it now sets
	    XmlResolver on text reader.
	  - On ID constraints check and type verification, it now uses
	    normalized attribute or its tokenized value(s).
	  - Fixed ValidateAttributes() to add default values when
	    ValidationType is Auto.
	* XmlParserContext.cs : added internal Dtd setter.
	* XmlParserInput.cs :
	  InsertParameterEntityBuffer() should add surrounding whitespaces.
	  Removed unused code block.
	* XmlTextReader.cs :
	  - Modified ReadReference(), ReadAttribute() and Dereference() to use
	    XmlChar.GetPredefinedEntity().
	  - When returning entity reference, it checks extity declaration
	    existence in certain conditions.
	  - ReadAttribute() now skips general entity replacement on reading
	    entity value.
	  - ReadText() now handles whitespace texts as XmlNodeType.Whitespace.
	  - ReadXmlDeclaration() holds isStandalone, which might be used in
	    entity reference's well-formedness check.
	  - internal 'DTD' now uses XmlParserContext.Dtd.
	  - isInternalSubset was meaningless. Now uses input stack's Count.
	  - Added some required SkipWhitespace().
	  - Several parameter entity handling changes.  Added GetPEValue(name).
	    TryExpandPERef() now uses ImportAsPERef(). ReadParameterEntityDecl()
	    now uses its Resolve() when it was external PE.  Now it uses value
	    buffer instead of currentTag, to efficiently read (included) PE.
	    CompileDeclaration() now uses ImportAsPERef instead of ExpandPERef().
	    ImportAsPERef() simply inserts the value to currentInput.
	    ReadEntityDecl() also uses value buffer.   Removed non-used methods.
	  - Default attributes are now stored in normalized form.
	  - Dereference() now considers non-expanding predefined entities.
	* XmlValidatingReader.cs : now holds Schemas, and ValidationType.Auto
	  is more correctly supported.

	* XmlAttributeCollection.cs :
	  When removing default attribute, it immediately inserts the attribute.
	  RemoveAll() should consider default (not-removable) attributes.
	* XmlDocument.cs :
	  Should have its default XmlResolver. Added Internal Resolver.
	  Some Load() should use its XmlResolver.
	  ImportNode() should copy its children in node level, not value level.
	  It also have to consider not to copy default attribute on importing
	  XmlElement.
	* XmlDocumentType.cs : Now uses document's XmlResolver to read DTD.
	* XmlAttribute.cs,
	  XmlDocumentFragment.cs.
	  XmlElement.cs : use XmlResolver on InnerXml. Removed some MonoTODO.
	* XmlNodeReader.cs : GetInternalParserConext() should provide its DTD.
	  ResolveEntity() uses XmlResolver on entityReader.

svn path=/trunk/mcs/; revision=17202
2003-08-09 09:48:35 +00:00

133 lines
3.0 KiB
C#

//
// System.Xml.XmlDocumentFragment
//
// Author:
// Duncan Mak ([email protected])
// Atsushi Enomoto ([email protected])
//
// (C), Ximian, Inc
// (C)2002 Atsushi Enomoto
using System;
using System.IO;
using System.Text;
using System.Xml.XPath;
namespace System.Xml
{
public class XmlDocumentFragment : XmlNode
{
#region Fields
private XmlLinkedNode lastLinkedChild;
#endregion
#region Constructor
protected internal XmlDocumentFragment (XmlDocument doc)
: base (doc)
{
}
#endregion
#region Properties
[MonoTODO("Setter is as incomplete as that of XmlElement.InnerXml")]
public override string InnerXml {
set {
// Copied from XmlElement.InnerXml (in the meantime;-))
foreach(XmlNode n in ChildNodes)
{
this.RemoveChild (n);
}
// 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 ();
foreach(XmlNode n in ChildNodes)
sb.Append (n.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.
}
// It is really not a type of XmlLinkedNode,
// but I copied this way from XmlElement. It looks good.
internal override XmlLinkedNode LastLinkedChild
{
get { return lastLinkedChild; }
set { lastLinkedChild = value; }
}
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)
{
foreach(XmlNode n in ChildNodes)
n.WriteContentTo (w);
}
public override void WriteTo (XmlWriter w)
{
foreach(XmlNode n in ChildNodes)
n.WriteTo (w);
}
#endregion
}
}