Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/System.XML/System.Xml')
-rw-r--r--mcs/class/System.XML/System.Xml/ChangeLog54
-rw-r--r--mcs/class/System.XML/System.Xml/XmlAttribute.cs15
-rw-r--r--mcs/class/System.XML/System.Xml/XmlElement.cs8
-rw-r--r--mcs/class/System.XML/System.Xml/XmlNode.cs4
-rw-r--r--mcs/class/System.XML/System.Xml/XmlTextReader.cs93
-rw-r--r--mcs/class/System.XML/System.Xml/XmlTextWriter.cs27
-rw-r--r--mcs/class/System.XML/System.Xml/XmlWriter.cs2
7 files changed, 56 insertions, 147 deletions
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog
index 6da24f7f434..04516da68e3 100644
--- a/mcs/class/System.XML/System.Xml/ChangeLog
+++ b/mcs/class/System.XML/System.Xml/ChangeLog
@@ -1,57 +1,3 @@
-2004-09-06 Atsushi Enomoto <atsushi@ximian.com>
-
- * XmlWriter.cs : on reader.NodeType is None, WriteNode() still tries
- to read more (and might result in an error).
-
-2004-09-03 Atsushi Enomoto <atsushi@ximian.com>
-
- * XmlTextReader.cs : When Normalization is true, CRLF and CR should
- be converted to single LF. This should fix part of bug #62076.
-
-2004-08-27 Atsushi Enomoto <atsushi@ximian.com>
-
- * XmlAttribute.cs : some property getters threw NullReferenceException
- when the attribute is not added to an element.
- * XmlNode.cs : When a node is not appended to another node, BaseURI
- is empty. Bug #64120 is fixed.
-
-2004-08-26 Atsushi Enomoto <atsushi@ximian.com>
-
- * XmlTextWriter.cs : In CheckState(), don't create indentation string
- at every time. WriteIndent() now handles the indentation without
- recomputation.
-
-2004-08-21 Atsushi Enomoto <atsushi@ximian.com>
-
- * XmlElement.cs : set_InnerText was removing children incompletely.
- This fixes bug #63574.
-
-2004-08-20 Atsushi Enomoto <atsushi@ximian.com>
-
- ResetState() now throws InvalidOperationException() as MS.NET does.
-
-2004-08-20 Atsushi Enomoto <atsushi@ximian.com>
-
- * XmlTextReader.cs : Fixed EOF not to return true when it is just
- closed. Element and EndElement location is now adjusted to be the
- same as MS.NET does. This fixes bug #63505 and #63507.
-
-2004-07-28 Lluis Sanchez Gual <lluis@novell.com>
-
- * XmlTextReader.cs: Stop parsing when a null character is found.
-
-2004-07-20 Atsushi Enomoto <atsushi@ximian.com>
-
- * XmlNode.cs : When the argument node being inserted is the existing
- document element, it should not result in an error (since it should
- be first removed from document, thus no error should happen).
-
-2004-07-16 Atsushi Enomoto <atsushi@ximian.com>
-
- * XmlTextReader.cs : Fixed several problems on ReadBase64();
- Whitespaces should be ignored, and '=' was not skipped correctly.
- It caused "unexpected end of document" error at immediate close tag.
-
2004-06-18 Atsushi Enomoto <atsushi@ximian.com>
* DTDObjectModel.cs, DTDReader.cs, XmlConvert.cs, XmlDocument.cs,
diff --git a/mcs/class/System.XML/System.Xml/XmlAttribute.cs b/mcs/class/System.XML/System.Xml/XmlAttribute.cs
index d02dee88e5c..f5bfcc958a0 100644
--- a/mcs/class/System.XML/System.Xml/XmlAttribute.cs
+++ b/mcs/class/System.XML/System.Xml/XmlAttribute.cs
@@ -104,7 +104,9 @@ namespace System.Xml
#region Properties
public override string BaseURI {
- get { return OwnerElement != null ? OwnerElement.BaseURI : String.Empty; }
+ get {
+ return OwnerElement.BaseURI;
+ }
}
public override string InnerText {
@@ -173,7 +175,9 @@ namespace System.Xml
}
public virtual XmlElement OwnerElement {
- get { return ownerElement; }
+ get {
+ return ownerElement;
+ }
}
public override XmlNode ParentNode {
@@ -244,11 +248,11 @@ namespace System.Xml
}
internal override string XmlLang {
- get { return OwnerElement != null ? OwnerElement.XmlLang : String.Empty; }
+ get { return OwnerElement.XmlLang; }
}
internal override XmlSpace XmlSpace {
- get { return OwnerElement != null ? OwnerElement.XmlSpace : XmlSpace.None; }
+ get { return OwnerElement.XmlSpace; }
}
#endregion
@@ -294,9 +298,6 @@ namespace System.Xml
internal DTDAttributeDefinition GetAttributeDefinition ()
{
- if (OwnerElement == null)
- return null;
-
// If it is default, then directly create new attribute.
DTDAttListDeclaration attList = OwnerDocument.DocumentType != null ? OwnerDocument.DocumentType.DTD.AttListDecls [OwnerElement.Name] : null;
return attList != null ? attList [Name] : null;
diff --git a/mcs/class/System.XML/System.Xml/XmlElement.cs b/mcs/class/System.XML/System.Xml/XmlElement.cs
index f506853124d..a74d801671c 100644
--- a/mcs/class/System.XML/System.Xml/XmlElement.cs
+++ b/mcs/class/System.XML/System.Xml/XmlElement.cs
@@ -115,11 +115,13 @@ namespace System.Xml
}
set {
// Why its behavior (of MS FCL) is different from InnerXml...?
- if (ChildNodes != null && ChildNodes.Count == 1 && FirstChild.NodeType == XmlNodeType.Text)
+ if (FirstChild != null && FirstChild.NodeType == XmlNodeType.Text)
FirstChild.Value = value;
else {
- while (FirstChild != null)
- this.RemoveChild (FirstChild);
+ if (FirstChild != null) {
+ for (int i = 0; i < ChildNodes.Count; i++)
+ this.RemoveChild (ChildNodes [i]);
+ }
// creates new Text node
AppendChild (OwnerDocument.CreateTextNode (value));
}
diff --git a/mcs/class/System.XML/System.Xml/XmlNode.cs b/mcs/class/System.XML/System.Xml/XmlNode.cs
index ef1ec861a31..52c6b21c794 100644
--- a/mcs/class/System.XML/System.Xml/XmlNode.cs
+++ b/mcs/class/System.XML/System.Xml/XmlNode.cs
@@ -71,7 +71,7 @@ namespace System.Xml
get {
// Isn't it conformant to W3C XML Base Recommendation?
// As far as I tested, there are not...
- return (ParentNode != null) ? ParentNode.BaseURI : String.Empty;
+ return (ParentNode != null) ? ParentNode.BaseURI : OwnerDocument.BaseURI;
}
}
@@ -524,7 +524,7 @@ namespace System.Xml
throw new ArgumentException ("The reference node is not a child of this node.");
}
- if(this == ownerDoc && ownerDoc.DocumentElement != null && (newChild is XmlElement) && newChild != ownerDoc.DocumentElement)
+ if(this == ownerDoc && ownerDoc.DocumentElement != null && (newChild is XmlElement))
throw new XmlException ("multiple document element not allowed.");
// checking validity finished. then appending...
diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader.cs b/mcs/class/System.XML/System.Xml/XmlTextReader.cs
index 221541167bf..ea3b4e9cd51 100644
--- a/mcs/class/System.XML/System.Xml/XmlTextReader.cs
+++ b/mcs/class/System.XML/System.Xml/XmlTextReader.cs
@@ -176,8 +176,14 @@ namespace System.Xml
}
#endif
- public override bool EOF {
- get { return readState == ReadState.EndOfFile; }
+ public override bool EOF
+ {
+ get
+ {
+ return
+ readState == ReadState.EndOfFile ||
+ readState == ReadState.Closed;
+ }
}
#if NET_2_0
@@ -525,14 +531,6 @@ namespace System.Xml
return false;
}
- private int SkipIgnorableBase64Chars (char [] chars, int charsLength, int i)
- {
- while (chars [i] == '=' || XmlChar.IsWhitespace (chars [i]))
- if (charsLength == ++i)
- break;
- return i;
- }
-
public int ReadBase64 (byte [] buffer, int offset, int length)
{
if (offset < 0)
@@ -569,9 +567,7 @@ namespace System.Xml
byte b = 0;
byte work = 0;
- for (int i = 0; i < charsLength - 3; i++) {
- if ((i = SkipIgnorableBase64Chars (chars, charsLength, i)) == charsLength)
- break;
+ for (int i = 0; i < charsLength - 3; i += 4) {
b = (byte) (GetBase64Byte (chars [i]) << 2);
if (bufIndex < bufLast)
buffer [bufIndex] = b;
@@ -581,11 +577,9 @@ namespace System.Xml
base64Cache [0] = b;
}
// charsLength mod 4 might not equals to 0.
- if (++i == charsLength)
+ if (i + 1 == charsLength)
break;
- if ((i = SkipIgnorableBase64Chars (chars, charsLength, i)) == charsLength)
- break;
- b = GetBase64Byte (chars [i]);
+ b = GetBase64Byte (chars [i + 1]);
work = (byte) (b >> 4);
if (bufIndex < bufLast) {
buffer [bufIndex] += work;
@@ -604,11 +598,9 @@ namespace System.Xml
base64Cache [1] = work;
}
- if (++i == charsLength)
- break;
- if ((i = SkipIgnorableBase64Chars (chars, charsLength, i)) == charsLength)
+ if (i + 2 == charsLength)
break;
- b = GetBase64Byte (chars [i]);
+ b = GetBase64Byte (chars [i + 2]);
work = (byte) (b >> 2);
if (bufIndex < bufLast) {
buffer [bufIndex] += work;
@@ -625,11 +617,9 @@ namespace System.Xml
base64CacheStartsAt = 2;
base64Cache [2] = work;
}
- if (++i == charsLength)
+ if (i + 3 == charsLength)
break;
- if ((i = SkipIgnorableBase64Chars (chars, charsLength, i)) == charsLength)
- break;
- work = GetBase64Byte (chars [i]);
+ work = GetBase64Byte (chars [i + 3]);
if (bufIndex < bufLast) {
buffer [bufIndex] += work;
bufIndex++;
@@ -682,7 +672,7 @@ namespace System.Xml
public void ResetState ()
{
- throw new InvalidOperationException ("Cannot call ResetState when parsing an XML fragment.");
+ Init ();
}
public override void ResolveEntity ()
@@ -1140,11 +1130,8 @@ namespace System.Xml
return -1;
return PeekChar ();
}
- else {
- char c = peekChars [peekCharsIndex];
- if (c != 0) return c;
- else return -1;
- }
+ else
+ return peekChars [peekCharsIndex];
}
private int ReadChar ()
@@ -1161,8 +1148,6 @@ namespace System.Xml
if (ch == '\n') {
line++;
column = 1;
- } else if (ch == 0) {
- return -1;
} else {
column++;
}
@@ -1298,9 +1283,6 @@ namespace System.Xml
"Multiple document element was detected.");
currentState = XmlNodeType.Element;
- currentLinkedNodeLineNumber = line;
- currentLinkedNodeLinePosition = column;
-
parserContext.NamespaceManager.PushScope ();
string name = ReadName ();
@@ -1403,9 +1385,6 @@ namespace System.Xml
throw new XmlException (this as IXmlLineInfo,
"End tag cannot appear in this state.");
- currentLinkedNodeLineNumber = line;
- currentLinkedNodeLinePosition = column;
-
string name = ReadName ();
if (elementNameStackPos == 0)
throw new XmlException (this as IXmlLineInfo,"closing element without matching opening element");
@@ -1548,14 +1527,8 @@ namespace System.Xml
ch = ReadReference (false);
if (returnEntityReference) // Returns -1 if char validation should not be done
break;
- } else if (normalization && ch == '\r') {
- ReadChar ();
- ch = ReadChar ();
- if (ch != '\n')
- // append '\n' instead of '\r'.
- AppendValueChar ('\n');
- // and in case of "\r\n", discard '\r'.
- } else {
+ }
+ else {
if (XmlChar.IsInvalid (ch))
throw new XmlException (this, "Not allowed character was found.");
ch = ReadChar ();
@@ -2148,18 +2121,8 @@ namespace System.Xml
skip = true;
}
}
- if (normalization) {
- if (ch == '\r') {
- ch = PeekChar ();
- if (ch != '\n')
- // append '\n' instead of '\r'.
- AppendValueChar ('\n');
- // otherwise, discard '\r'.
- continue;
- }
- else if (XmlChar.IsInvalid (ch))
- throw new XmlException (this, "Invalid character was found.");
- }
+ if (normalization && XmlChar.IsInvalid (ch))
+ throw new XmlException (this, "Invalid character was found.");
AppendValueChar (ch);
}
@@ -2585,8 +2548,6 @@ namespace System.Xml
return;
}
- // Since ReadBase64() is processed for every 4 chars, it does
- // not handle '=' here.
private byte GetBase64Byte (char ch)
{
switch (ch) {
@@ -2594,6 +2555,8 @@ namespace System.Xml
return 62;
case '/':
return 63;
+ case '=':
+ return 0;
default:
if (ch >= 'A' && ch <= 'Z')
return (byte) (ch - 'A');
@@ -2614,6 +2577,8 @@ namespace System.Xml
return 0;
}
+ shouldSkipUntilEndTag = true;
+
if (offset < 0)
throw new ArgumentOutOfRangeException ("offset", offset, "Offset must be non-negative integer.");
else if (length < 0)
@@ -2624,8 +2589,6 @@ namespace System.Xml
if (NodeType != XmlNodeType.Element)
return 0;
- shouldSkipUntilEndTag = true;
-
int bufIndex = offset;
for (int i = 0; i < length; i++) {
int c = PeekChar ();
@@ -2644,9 +2607,9 @@ namespace System.Xml
depth++;
depthUp = false;
}
- ReadEndTag ();
+ ReadEndTag();
shouldSkipUntilEndTag = false;
- Read (); // move to the next node
+ Read ();
return i;
default:
ReadChar ();
diff --git a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs
index 8e10329bf68..af19e18dc6b 100644
--- a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs
+++ b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs
@@ -277,9 +277,13 @@ openElements [openElementCount - 1]).IndentingOverriden;
}
if ((documentStarted == true) && (formatting == Formatting.Indented) && (!IndentingOverriden)) {
indentFormatting = w.NewLine;
+ if (indentLevel > 0) {
+ for (int i = 0; i < indentLevel; i++)
+ indentFormatting += indentChars;
+ }
}
else
- indentFormatting = null;
+ indentFormatting = "";
documentStarted = true;
}
@@ -337,7 +341,9 @@ openElements [openElementCount - 1]).IndentingOverriden;
private void UpdateIndentChars ()
{
- indentChars = new string (indentChar, indentation);
+ indentChars = "";
+ for (int i = 0; i < indentation; i++)
+ indentChars += indentChar;
}
public override void WriteBase64 (byte[] buffer, int index, int count)
@@ -529,15 +535,6 @@ openElements [openElementCount - 1]).IndentingOverriden;
WriteEndElementInternal (false);
}
- private void WriteIndent ()
- {
- if (indentFormatting == null)
- return;
- w.Write (w.NewLine);
- for (int i = 0; i < indentLevel; i++)
- w.Write (indentChars);
- }
-
private void WriteEndElementInternal (bool fullEndElement)
{
if (openElementCount == 0)
@@ -556,7 +553,7 @@ openElements [openElementCount - 1]).IndentingOverriden;
if (fullEndElement) {
w.Write ('>');
if (!ParentIndentingOverriden)
- WriteIndent ();
+ w.Write (indentFormatting);
w.Write ("</");
XmlTextWriterOpenElement el = (XmlTextWriterOpenElement) openElements [openElementCount - 1];
if (el.Prefix != String.Empty) {
@@ -571,7 +568,7 @@ openElements [openElementCount - 1]).IndentingOverriden;
openElementCount--;
openStartElement = false;
} else {
- WriteIndent ();
+ w.Write (indentFormatting);
w.Write ("</");
XmlTextWriterOpenElement el = (XmlTextWriterOpenElement) openElements [openElementCount - 1];
openElementCount--;
@@ -629,7 +626,7 @@ openElements [openElementCount - 1]).IndentingOverriden;
CheckState ();
CloseStartElement ();
- WriteIndent ();
+ w.Write (indentFormatting);
w.Write ("<?");
w.Write (name);
w.Write (' ');
@@ -837,7 +834,7 @@ openElements [openElementCount - 1]).IndentingOverriden;
if (prefix == null)
prefix = String.Empty;
- WriteIndent ();
+ w.Write (indentFormatting);
w.Write ('<');
if (prefix != String.Empty) {
w.Write (prefix);
diff --git a/mcs/class/System.XML/System.Xml/XmlWriter.cs b/mcs/class/System.XML/System.Xml/XmlWriter.cs
index 7e4fb8d6b28..4f69abaf378 100644
--- a/mcs/class/System.XML/System.Xml/XmlWriter.cs
+++ b/mcs/class/System.XML/System.Xml/XmlWriter.cs
@@ -273,7 +273,7 @@ namespace System.Xml
case XmlNodeType.EndEntity:
break;
case XmlNodeType.None:
- break; // Do nothing, nor reporting errors.
+ return; // Do nothing, nor reporting errors.
default:
throw new XmlException ("Unexpected node " + reader.Name + " of type " + reader.NodeType);
}