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')
-rw-r--r--mcs/class/System.XML/Mono.Xml.XPath/ChangeLog7
-rw-r--r--mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator.cs15
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog9
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs5
-rwxr-xr-xmcs/class/System.XML/Mono.Xml.Xsl/ScriptCompilerInfo.cs20
-rw-r--r--mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs52
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/ChangeLog11
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/SchemaDataValueType.cs10
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchema.cs5
-rwxr-xr-xmcs/class/System.XML/System.Xml.Serialization/ChangeLog16
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs2
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs1
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs4
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs2
-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
21 files changed, 280 insertions, 82 deletions
diff --git a/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog b/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog
index 053dc02ede2..c7d9e126328 100644
--- a/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog
+++ b/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog
@@ -1,3 +1,10 @@
+2004-07-30 Atsushi Enomoto <atsushi@ximian.com>
+
+ * DTMXPathNavigator.cs :
+ Fixed IsSamePosition(). currentAttr is not always the same as
+ that of other when current is not attribute. Ditto for currentNS
+ (when current is not namespace).
+
2004-06-06 Atsushi Enomoto <atsushi@ximian.com>
* DTMXPathDocumentBuilder.cs : Close XmlTextReader strictly. It might
diff --git a/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator.cs b/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator.cs
index abd904bc987..6bd8a339a0e 100644
--- a/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator.cs
+++ b/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator.cs
@@ -366,11 +366,16 @@ namespace Mono.Xml.XPath
if (another == null || another.document != this.document)
return false;
- return this.currentNode == another.currentNode &&
- this.currentAttr == another.currentAttr &&
- this.currentIsAttr == another.currentIsAttr &&
- this.currentIsNode == another.currentIsNode &&
- this.currentNs == another.currentNs;
+ if (this.currentNode != another.currentNode ||
+ this.currentIsAttr != another.currentIsAttr ||
+ this.currentIsNode != another.currentIsNode)
+ return false;
+
+ if (currentIsAttr)
+ return this.currentAttr == another.currentAttr;
+ else if (!currentIsNode)
+ return this.currentNs == another.currentNs;
+ return true;
}
public override bool MoveTo (XPathNavigator other)
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
index ece4b875d31..bb78351e9de 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
@@ -1,3 +1,12 @@
+2004-10-04 Atsushi Enomoto <atsushi@ximian.com>
+
+ * HtmlEmitter.cs : TH tag is not regarded as HTML tag.
+ This fixes bug #67390.
+
+Thu Sep 9 07:09:11 PDT 2004 Paolo Molaro <lupus@ximian.com>
+
+ * ScriptCompilerInfo.cs: avoid using a .cctor and fix precomp.
+
2004-06-18 Atsushi Enomoto <atsushi@ximian.com>
* Debug.cs, HtmlEmitter.cs, MSXslScriptManager.cs,
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs b/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs
index 39839561219..ad5872c3c9a 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs
@@ -226,9 +226,8 @@ namespace Mono.Xml.Xsl
case "SMALL": case "SPAN": case "STRIKE": case "STRONG":
case "STYLE": case "SUB": case "SUP":
case "TABLE": case "TBODY": case "TD": case "TEXTAREA":
- case "TFOOT": case "THEAD": case "TITLE": case "TR": case "TT":
- case "U": case "UL":
- case "VAR":
+ case "TFOOT": case "TH": case "THEAD": case "TITLE":
+ case "TR": case "TT": case "U": case "UL": case "VAR":
return true;
}
return false;
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/ScriptCompilerInfo.cs b/mcs/class/System.XML/Mono.Xml.Xsl/ScriptCompilerInfo.cs
index 0a5d72ed4cb..87438fa2bb0 100755
--- a/mcs/class/System.XML/Mono.Xml.Xsl/ScriptCompilerInfo.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/ScriptCompilerInfo.cs
@@ -216,12 +216,6 @@ end namespace
{
static Type providerType;
- static JScriptCompilerInfo ()
- {
- Assembly jsasm = Assembly.LoadWithPartialName ("Microsoft.JScript", null);
- providerType = jsasm.GetType ("Microsoft.JScript.JScriptCodeProvider");
- }
-
public JScriptCompilerInfo ()
{
this.CompilerCommand = "mjs";
@@ -231,9 +225,17 @@ end namespace
this.DefaultCompilerOptions = "/t:library /r:Microsoft.VisualBasic.dll";
}
- public override CodeDomProvider CodeDomProvider {
- get { return (CodeDomProvider) Activator.CreateInstance (providerType); }
- }
+ public override CodeDomProvider CodeDomProvider {
+ get {
+ // no need for locking
+ if (providerType == null) {
+ Assembly jsasm = Assembly.LoadWithPartialName ("Microsoft.JScript", null);
+ if (jsasm != null)
+ providerType = jsasm.GetType ("Microsoft.JScript.JScriptCodeProvider");
+ }
+ return (CodeDomProvider) Activator.CreateInstance (providerType);
+ }
+ }
public override string Extension {
get { return ".js"; }
diff --git a/mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs b/mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs
index 8402f2d8004..4587f204179 100644
--- a/mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs
+++ b/mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs
@@ -1370,15 +1370,61 @@ namespace Mono.Xml.Schema
public override object ParseValue (string s,
XmlNameTable nameTable, XmlNamespaceManager nsmgr)
{
- return ParseValueType (s, nameTable, nsmgr);
+ return new XmlSchemaUri (Normalize (s));
}
internal override ValueType ParseValueType (string s, XmlNameTable nameTable, XmlNamespaceManager nsmgr)
{
- return new UriValueType (Normalize (s));
+ return new UriValueType ((XmlSchemaUri) ParseValue (s, nameTable, nsmgr));
}
}
-
+
+ internal class XmlSchemaUri : Uri
+ {
+ public string value;
+
+ // LAMESPEC: In this way, some strings that contain ':' might
+ // result in exception (MS.NET looks implemented as such).
+ public XmlSchemaUri (string src)
+ : this (src, src.IndexOf (':') > 0)
+ {
+ }
+
+ private XmlSchemaUri (string src, bool formal)
+ : base (formal ? src : "anyuri:" + src, !formal)
+ {
+ value = src;
+ }
+
+ public static bool operator == (XmlSchemaUri v1, XmlSchemaUri v2)
+ {
+ return v1.value == v2.value;
+ }
+
+ public static bool operator != (XmlSchemaUri v1, XmlSchemaUri v2)
+ {
+ return v1.value != v2.value;
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (obj is XmlSchemaUri)
+ return (XmlSchemaUri) obj == this;
+ else
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ return value.GetHashCode ();
+ }
+
+ public override string ToString ()
+ {
+ return value;
+ }
+ }
+
// xs:duration
internal class XsdDuration : XsdAnySimpleType
{
diff --git a/mcs/class/System.XML/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
index 14dd692e892..e3dc9a5679f 100755
--- a/mcs/class/System.XML/System.Xml.Schema/ChangeLog
+++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
@@ -1,3 +1,14 @@
+2004-09-16 Atsushi Enomoto <atsushi@ximian.com>
+
+ * BuiltInDatatype.cs, SchemaDataValueType.cs :
+ ParseValue() for xs:AnyURI should return System.Uri. MS.NET returns
+ XmlSchemaUri, but it is derived from System.Uri, while ours was not.
+
+2004-09-03 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlSchema.cs : When schema inclusion results in a recursion, just
+ skip recursed schema.
+
2004-06-18 Atsushi Enomoto <atsushi@ximian.com>
* CustomSerializer.cs, XmlSchemaException.cs,
diff --git a/mcs/class/System.XML/System.Xml.Schema/SchemaDataValueType.cs b/mcs/class/System.XML/System.Xml.Schema/SchemaDataValueType.cs
index c2b9305fcad..ff4031f2806 100755
--- a/mcs/class/System.XML/System.Xml.Schema/SchemaDataValueType.cs
+++ b/mcs/class/System.XML/System.Xml.Schema/SchemaDataValueType.cs
@@ -19,6 +19,8 @@
// 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 Mono.Xml.Schema;
+
namespace System.Xml.Schema
{
internal struct QNameValueType
@@ -97,14 +99,14 @@ namespace System.Xml.Schema
internal struct UriValueType
{
- string value;
+ XmlSchemaUri value;
- public UriValueType (string value)
+ public UriValueType (XmlSchemaUri value)
{
this.value = value;
}
- public string Value {
+ public XmlSchemaUri Value {
get { return value; }
}
@@ -133,7 +135,7 @@ namespace System.Xml.Schema
public override string ToString ()
{
- return value;
+ return value.ToString ();
}
}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs
index 59e28520089..6e37d9f3be6 100755
--- a/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs
@@ -369,7 +369,10 @@ namespace System.Xml.Schema
if (resolver != null) {
url = GetResolvedUri (resolver, ext.SchemaLocation);
if (schemaLocationStack.Contains (url)) {
- error(handler, "Nested inclusion was found: " + url);
+ // Just skip nested inclusion.
+ // The spec is "carefully written"
+ // not to handle it as an error.
+ // error (handler, "Nested inclusion was found: " + url);
// must skip this inclusion
continue;
}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/ChangeLog b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
index f98edd97e7f..0586af82013 100755
--- a/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
+++ b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
@@ -1,3 +1,19 @@
+2004-09-28 Lluis Sanchez Gual <lluis@novell.com>
+
+ * CodeIdentifier.cs: MakeValid now returns "Item" for an empty string.
+ This fixes bug #66877.
+
+2004-09-03 Lluis Sanchez Gual <lluis@novell.com>
+
+ * XmlSerializer.cs: When the XmlReader is created by XmlSerializer, use
+ Normalization==true by default.
+
+2004-07-15 Lluis Sanchez Gual <lluis@novell.com>
+
+ * TypeTranslator.cs, XmlCustomFormatter.cs: Added support for base64. This
+ xsd type is not part of the last schema specification, but the google api
+ uses it and ms.net accepts it.
+
2004-06-22 Lluis Sanchez Gual <lluis@ximian.com>
* ReflectionHelper.cs: Correctly detect private types.
diff --git a/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs b/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs
index 93d78b2f69f..54c0b6bee87 100644
--- a/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs
+++ b/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs
@@ -55,7 +55,7 @@ namespace System.Xml.Serialization {
if (identifier == null)
throw new NullReferenceException ();
if (identifier.Length == 0)
- return identifier;
+ return "Item";
string output = "";
diff --git a/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs b/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs
index cffcb1567a1..fc71eeea981 100644
--- a/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs
+++ b/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs
@@ -106,6 +106,7 @@ namespace System.Xml.Serialization
primitiveTypes.Add ("token", new TypeData (typeof (string), "token", true));
primitiveTypes.Add ("normalizedString", new TypeData (typeof (string), "normalizedString", true));
primitiveTypes.Add ("anyURI", new TypeData (typeof (string), "anyURI", true));
+ primitiveTypes.Add ("base64", new TypeData (typeof (byte[]), "base64", true));
}
public static TypeData GetTypeData (Type type)
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs
index 17514268a90..60b4f282cab 100644
--- a/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs
@@ -195,6 +195,7 @@ namespace System.Xml.Serialization {
case "unsignedInt": return XmlConvert.ToString ((UInt32)value);
case "unsignedLong": return XmlConvert.ToString ((UInt64)value);
case "guid": return XmlConvert.ToString ((Guid)value);
+ case "base64":
case "base64Binary": return Convert.ToBase64String ((byte[])value);
default: return value is IFormattable ? ((IFormattable) value).ToString (null, CultureInfo.InvariantCulture) : value.ToString ();
}
@@ -223,6 +224,7 @@ namespace System.Xml.Serialization {
case "unsignedInt": return XmlConvert.ToUInt32 (value);
case "unsignedLong": return XmlConvert.ToUInt64 (value);
case "guid": return XmlConvert.ToGuid (value);
+ case "base64":
case "base64Binary": return Convert.FromBase64String (value);
default:
if (type.Type != null)
@@ -253,6 +255,7 @@ namespace System.Xml.Serialization {
case "unsignedInt": return value + ".ToString(CultureInfo.InvariantCulture)";
case "unsignedLong": return value + ".ToString(CultureInfo.InvariantCulture)";
case "guid": return "XmlConvert.ToString (" + value + ")";
+ case "base64":
case "base64Binary": return "Convert.ToBase64String (" + value + ")";
case "NMTOKEN":
case "Name":
@@ -290,6 +293,7 @@ namespace System.Xml.Serialization {
case "unsignedInt": return "UInt32.Parse (" + value + ", CultureInfo.InvariantCulture)";
case "unsignedLong": return "UInt64.Parse (" + value + ", CultureInfo.InvariantCulture)";
case "guid": return "XmlConvert.ToGuid (" + value + ")";
+ case "base64:":
case "base64Binary": return "Convert.FromBase64String (" + value + ")";
default: return value;
}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs
index d5efa65c1d3..aa57189fb34 100644
--- a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs
@@ -251,12 +251,14 @@ namespace System.Xml.Serialization
public object Deserialize (Stream stream)
{
XmlTextReader xmlReader = new XmlTextReader(stream);
+ xmlReader.Normalization = true;
return Deserialize(xmlReader);
}
public object Deserialize (TextReader textReader)
{
XmlTextReader xmlReader = new XmlTextReader(textReader);
+ xmlReader.Normalization = true;
return Deserialize(xmlReader);
}
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog
index 04516da68e3..6da24f7f434 100644
--- a/mcs/class/System.XML/System.Xml/ChangeLog
+++ b/mcs/class/System.XML/System.Xml/ChangeLog
@@ -1,3 +1,57 @@
+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 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 52c6b21c794..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;
}
}
@@ -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))
+ if(this == ownerDoc && ownerDoc.DocumentElement != null && (newChild is XmlElement) && newChild != ownerDoc.DocumentElement)
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 ea3b4e9cd51..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
@@ -531,6 +525,14 @@ 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)
@@ -567,7 +569,9 @@ namespace System.Xml
byte b = 0;
byte work = 0;
- for (int i = 0; i < charsLength - 3; i += 4) {
+ for (int i = 0; i < charsLength - 3; i++) {
+ if ((i = SkipIgnorableBase64Chars (chars, charsLength, i)) == charsLength)
+ break;
b = (byte) (GetBase64Byte (chars [i]) << 2);
if (bufIndex < bufLast)
buffer [bufIndex] = b;
@@ -577,9 +581,11 @@ namespace System.Xml
base64Cache [0] = b;
}
// charsLength mod 4 might not equals to 0.
- if (i + 1 == charsLength)
+ if (++i == charsLength)
break;
- b = GetBase64Byte (chars [i + 1]);
+ if ((i = SkipIgnorableBase64Chars (chars, charsLength, i)) == charsLength)
+ break;
+ b = GetBase64Byte (chars [i]);
work = (byte) (b >> 4);
if (bufIndex < bufLast) {
buffer [bufIndex] += work;
@@ -598,9 +604,11 @@ namespace System.Xml
base64Cache [1] = work;
}
- if (i + 2 == charsLength)
+ if (++i == charsLength)
+ break;
+ if ((i = SkipIgnorableBase64Chars (chars, charsLength, i)) == charsLength)
break;
- b = GetBase64Byte (chars [i + 2]);
+ b = GetBase64Byte (chars [i]);
work = (byte) (b >> 2);
if (bufIndex < bufLast) {
buffer [bufIndex] += work;
@@ -617,9 +625,11 @@ namespace System.Xml
base64CacheStartsAt = 2;
base64Cache [2] = work;
}
- if (i + 3 == charsLength)
+ if (++i == charsLength)
break;
- work = GetBase64Byte (chars [i + 3]);
+ if ((i = SkipIgnorableBase64Chars (chars, charsLength, i)) == charsLength)
+ break;
+ work = GetBase64Byte (chars [i]);
if (bufIndex < bufLast) {
buffer [bufIndex] += work;
bufIndex++;
@@ -672,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 ()
@@ -1130,8 +1140,11 @@ namespace System.Xml
return -1;
return PeekChar ();
}
- else
- return peekChars [peekCharsIndex];
+ else {
+ char c = peekChars [peekCharsIndex];
+ if (c != 0) return c;
+ else return -1;
+ }
}
private int ReadChar ()
@@ -1148,6 +1161,8 @@ namespace System.Xml
if (ch == '\n') {
line++;
column = 1;
+ } else if (ch == 0) {
+ return -1;
} else {
column++;
}
@@ -1283,6 +1298,9 @@ namespace System.Xml
"Multiple document element was detected.");
currentState = XmlNodeType.Element;
+ currentLinkedNodeLineNumber = line;
+ currentLinkedNodeLinePosition = column;
+
parserContext.NamespaceManager.PushScope ();
string name = ReadName ();
@@ -1385,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");
@@ -1527,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 ();
@@ -2121,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);
}
@@ -2548,6 +2585,8 @@ namespace System.Xml
return;
}
+ // Since ReadBase64() is processed for every 4 chars, it does
+ // not handle '=' here.
private byte GetBase64Byte (char ch)
{
switch (ch) {
@@ -2555,8 +2594,6 @@ namespace System.Xml
return 62;
case '/':
return 63;
- case '=':
- return 0;
default:
if (ch >= 'A' && ch <= 'Z')
return (byte) (ch - 'A');
@@ -2577,8 +2614,6 @@ 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)
@@ -2589,6 +2624,8 @@ namespace System.Xml
if (NodeType != XmlNodeType.Element)
return 0;
+ shouldSkipUntilEndTag = true;
+
int bufIndex = offset;
for (int i = 0; i < length; i++) {
int c = PeekChar ();
@@ -2607,9 +2644,9 @@ namespace System.Xml
depth++;
depthUp = false;
}
- ReadEndTag();
+ ReadEndTag ();
shouldSkipUntilEndTag = false;
- Read ();
+ Read (); // move to the next node
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 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);
}