diff options
Diffstat (limited to 'mcs/class/System.XML/System.Xml')
-rw-r--r-- | mcs/class/System.XML/System.Xml/ChangeLog | 38 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlAttribute.cs | 15 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlElement.cs | 8 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlNode.cs | 2 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlTextReader.cs | 42 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlTextWriter.cs | 27 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlWriter.cs | 2 |
7 files changed, 94 insertions, 40 deletions
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index d0f99f7305e..6da24f7f434 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,3 +1,41 @@ +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. diff --git a/mcs/class/System.XML/System.Xml/XmlAttribute.cs b/mcs/class/System.XML/System.Xml/XmlAttribute.cs index f5bfcc958a0..d02dee88e5c 100644 --- a/mcs/class/System.XML/System.Xml/XmlAttribute.cs +++ b/mcs/class/System.XML/System.Xml/XmlAttribute.cs @@ -104,9 +104,7 @@ namespace System.Xml #region Properties public override string BaseURI { - get { - return OwnerElement.BaseURI; - } + get { return OwnerElement != null ? OwnerElement.BaseURI : String.Empty; } } public override string InnerText { @@ -175,9 +173,7 @@ namespace System.Xml } public virtual XmlElement OwnerElement { - get { - return ownerElement; - } + get { return ownerElement; } } public override XmlNode ParentNode { @@ -248,11 +244,11 @@ namespace System.Xml } internal override string XmlLang { - get { return OwnerElement.XmlLang; } + get { return OwnerElement != null ? OwnerElement.XmlLang : String.Empty; } } internal override XmlSpace XmlSpace { - get { return OwnerElement.XmlSpace; } + get { return OwnerElement != null ? OwnerElement.XmlSpace : XmlSpace.None; } } #endregion @@ -298,6 +294,9 @@ 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 a74d801671c..f506853124d 100644 --- a/mcs/class/System.XML/System.Xml/XmlElement.cs +++ b/mcs/class/System.XML/System.Xml/XmlElement.cs @@ -115,13 +115,11 @@ namespace System.Xml } set { // Why its behavior (of MS FCL) is different from InnerXml...? - if (FirstChild != null && FirstChild.NodeType == XmlNodeType.Text) + if (ChildNodes != null && ChildNodes.Count == 1 && FirstChild.NodeType == XmlNodeType.Text) FirstChild.Value = value; else { - if (FirstChild != null) { - for (int i = 0; i < ChildNodes.Count; i++) - this.RemoveChild (ChildNodes [i]); - } + while (FirstChild != null) + this.RemoveChild (FirstChild); // 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 7eaa7285c8e..ef1ec861a31 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 : OwnerDocument.BaseURI; + return (ParentNode != null) ? ParentNode.BaseURI : String.Empty; } } diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader.cs b/mcs/class/System.XML/System.Xml/XmlTextReader.cs index d37332a0508..221541167bf 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextReader.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextReader.cs @@ -176,14 +176,8 @@ namespace System.Xml } #endif - public override bool EOF - { - get - { - return - readState == ReadState.EndOfFile || - readState == ReadState.Closed; - } + public override bool EOF { + get { return readState == ReadState.EndOfFile; } } #if NET_2_0 @@ -688,7 +682,7 @@ namespace System.Xml public void ResetState () { - Init (); + throw new InvalidOperationException ("Cannot call ResetState when parsing an XML fragment."); } public override void ResolveEntity () @@ -1304,6 +1298,9 @@ namespace System.Xml "Multiple document element was detected."); currentState = XmlNodeType.Element; + currentLinkedNodeLineNumber = line; + currentLinkedNodeLinePosition = column; + parserContext.NamespaceManager.PushScope (); string name = ReadName (); @@ -1406,6 +1403,9 @@ 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,8 +1548,14 @@ namespace System.Xml ch = ReadReference (false); if (returnEntityReference) // Returns -1 if char validation should not be done break; - } - else { + } 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 { if (XmlChar.IsInvalid (ch)) throw new XmlException (this, "Not allowed character was found."); ch = ReadChar (); @@ -2142,8 +2148,18 @@ namespace System.Xml skip = true; } } - if (normalization && XmlChar.IsInvalid (ch)) - throw new XmlException (this, "Invalid character was found."); + 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."); + } AppendValueChar (ch); } diff --git a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs index af19e18dc6b..8e10329bf68 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs @@ -277,13 +277,9 @@ 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 = ""; + indentFormatting = null; documentStarted = true; } @@ -341,9 +337,7 @@ openElements [openElementCount - 1]).IndentingOverriden; private void UpdateIndentChars () { - indentChars = ""; - for (int i = 0; i < indentation; i++) - indentChars += indentChar; + indentChars = new string (indentChar, indentation); } public override void WriteBase64 (byte[] buffer, int index, int count) @@ -535,6 +529,15 @@ 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) @@ -553,7 +556,7 @@ openElements [openElementCount - 1]).IndentingOverriden; if (fullEndElement) { w.Write ('>'); if (!ParentIndentingOverriden) - w.Write (indentFormatting); + WriteIndent (); w.Write ("</"); XmlTextWriterOpenElement el = (XmlTextWriterOpenElement) openElements [openElementCount - 1]; if (el.Prefix != String.Empty) { @@ -568,7 +571,7 @@ openElements [openElementCount - 1]).IndentingOverriden; openElementCount--; openStartElement = false; } else { - w.Write (indentFormatting); + WriteIndent (); w.Write ("</"); XmlTextWriterOpenElement el = (XmlTextWriterOpenElement) openElements [openElementCount - 1]; openElementCount--; @@ -626,7 +629,7 @@ openElements [openElementCount - 1]).IndentingOverriden; CheckState (); CloseStartElement (); - w.Write (indentFormatting); + WriteIndent (); w.Write ("<?"); w.Write (name); w.Write (' '); @@ -834,7 +837,7 @@ openElements [openElementCount - 1]).IndentingOverriden; if (prefix == null) prefix = String.Empty; - w.Write (indentFormatting); + WriteIndent (); 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 4f69abaf378..7e4fb8d6b28 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: - return; // Do nothing, nor reporting errors. + break; // Do nothing, nor reporting errors. default: throw new XmlException ("Unexpected node " + reader.Name + " of type " + reader.NodeType); } |