2004-06-18 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 18 Jun 2004 01:22:07 +0000 (01:22 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 18 Jun 2004 01:22:07 +0000 (01:22 -0000)
* DTDObjectModel.cs, DTDReader.cs, XmlConvert.cs, XmlDocument.cs,
  XmlException.cs, XmlParserInput.cs, XmlTextReader.cs,
  XmlTextWriter.cs : Globalization.
* XmlNode.cs : Fixed error message that confused node type.

svn path=/trunk/mcs/; revision=29825

mcs/class/System.XML/System.Xml/ChangeLog
mcs/class/System.XML/System.Xml/DTDObjectModel.cs
mcs/class/System.XML/System.Xml/DTDReader.cs
mcs/class/System.XML/System.Xml/XmlConvert.cs
mcs/class/System.XML/System.Xml/XmlDocument.cs
mcs/class/System.XML/System.Xml/XmlException.cs
mcs/class/System.XML/System.Xml/XmlNode.cs
mcs/class/System.XML/System.Xml/XmlParserInput.cs
mcs/class/System.XML/System.Xml/XmlTextReader.cs
mcs/class/System.XML/System.Xml/XmlTextWriter.cs

index 64e2aeb833408f48612637f486ae2e8d6fb6287d..04516da68e335425f4b771f35abef10dbbe82a69 100644 (file)
@@ -1,3 +1,10 @@
+2004-06-18  Atsushi Enomoto <atsushi@ximian.com>
+
+       * DTDObjectModel.cs, DTDReader.cs, XmlConvert.cs, XmlDocument.cs,
+         XmlException.cs, XmlParserInput.cs, XmlTextReader.cs,
+         XmlTextWriter.cs : Globalization.
+       * XmlNode.cs : Fixed error message that confused node type.
+
 2004-06-14  Atsushi Enomoto <atsushi@ximian.com>
 
        * XmlDocumentNavigator.cs : MoveToNext() should skip concatenating
index 9c83dd813a3fb0ca84c8a9d4fd16295b24ceeb4e..ccbd0d931e1b8473f1cbbae6fc1f5c329d0a2954 100644 (file)
@@ -626,7 +626,7 @@ namespace Mono.Xml
                                                resolvedNormalizedDefaultValue = 
                                                        (o is string []) ? 
                                                        String.Join (" ", (string []) o) :
-                                                       o.ToString ();
+                                                       o is IFormattable ? ((IFormattable) o).ToString (null, CultureInfo.InvariantCulture) : o.ToString ();
                                        } catch (Exception) {
                                                // This is for non-error-reporting reader
                                                resolvedNormalizedDefaultValue = Datatype.Normalize (s);
@@ -671,7 +671,7 @@ namespace Mono.Xml
                                        }
                                        else
                                                spec = value.Substring (next + 2, semicolon - next - 2);
-                                       sb.Append ((char) int.Parse (spec, style));
+                                       sb.Append ((char) int.Parse (spec, style, CultureInfo.InvariantCulture));
                                } else {
                                        sb.Append (value.Substring (pos, next - 1));
                                        string name = value.Substring (next + 1, semicolon - 2);
index a9902c421d8d05f81b9b99960df3f06dc1613007..060406fc5e525ea17ff1b7f9c1818ef163af6502 100644 (file)
@@ -715,13 +715,13 @@ namespace System.Xml
                        int ret = 0;
                        if (value [index] == 'x') {
                                try {
-                                       ret = int.Parse (value.Substring (index + 1, end - index - 1), NumberStyles.HexNumber);
+                                       ret = int.Parse (value.Substring (index + 1, end - index - 1), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
                                } catch (FormatException) {
                                        throw new XmlException (li, "Invalid number for a character reference.");
                                }
                        } else {
                                try {
-                                       ret = int.Parse (value.Substring (index, end - index));
+                                       ret = int.Parse (value.Substring (index, end - index), CultureInfo.InvariantCulture);
                                } catch (FormatException) {
                                        throw new XmlException (li, "Invalid number for a character reference.");
                                }
@@ -785,7 +785,8 @@ namespace System.Xml
                                return; // do nothing
                        }
                        // FIXME: These leading/trailing ' ' is anyways supplied inside this method!
-                       currentInput.InsertParameterEntityBuffer (" " + peDecl.ReplacementText + " ");
+//                     currentInput.InsertParameterEntityBuffer (" " + peDecl.ReplacementText + " ");
+                       currentInput.InsertParameterEntityBuffer (peDecl.ReplacementText);
                }
 
                // The reader is positioned on the head of the name.
@@ -1272,7 +1273,7 @@ namespace System.Xml
 
                        if (ch != expected) {
                                throw new XmlException (this as IXmlLineInfo,
-                                       String.Format (
+                                       String.Format (CultureInfo.InvariantCulture, 
                                                "expected '{0}' ({1:X}) but found '{2}' ({3:X})",
                                                (char) expected,
                                                expected,
@@ -1295,7 +1296,7 @@ namespace System.Xml
                                if (XmlChar.IsWhitespace (i))
                                        continue;
                                if (c != i)
-                                       throw new XmlException (this, String.Format ("Expected {0} but found {1} [{2}].", c, (char) i, i));
+                                       throw new XmlException (this, String.Format (CultureInfo.InvariantCulture, "Expected {0} but found {1} [{2}].", c, (char) i, i));
                                break;
                        }
                }
@@ -1480,6 +1481,7 @@ namespace System.Xml
                                        else
                                                throw new XmlException (this as IXmlLineInfo,
                                                        String.Format (
+                                                               CultureInfo.InvariantCulture,
                                                                "invalid hexadecimal digit: {0} (#x{1:X})",
                                                                (char) ch,
                                                                ch));
@@ -1493,6 +1495,7 @@ namespace System.Xml
                                        else
                                                throw new XmlException (this as IXmlLineInfo,
                                                        String.Format (
+                                                               CultureInfo.InvariantCulture,
                                                                "invalid decimal digit: {0} (#x{1:X})",
                                                                (char) ch,
                                                                ch));
index fec8a03c3c6f09388d4128b606ef3f88d03a0c57..b5f07bfc79d2ca3e8c675e14e22fcff141dd13b7 100755 (executable)
@@ -107,7 +107,7 @@ namespace System.Xml {
 
                        char c = '\uFFFF';
                        try {
-                               c = (char) Int32.Parse (s.Substring (1, 4), NumberStyles.HexNumber);
+                               c = (char) Int32.Parse (s.Substring (1, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
                        } catch {
                                return s [0] + DecodeName (s.Substring (1));
                        }
@@ -436,7 +436,7 @@ namespace System.Xml {
                                        if (!Char.IsDigit (s [i]))
                                                break;
                                }
-                               int value = int.Parse (s.Substring (start, i - start));
+                               int value = int.Parse (s.Substring (start, i - start), CultureInfo.InvariantCulture);
                                switch (s [i]) {
                                case 'Y':
                                        days += value * 365;
index fbd5e532583f10f4d657859af9753c56c535088d..30aea6653a450344aa592adac41be33f54126141 100644 (file)
@@ -15,6 +15,7 @@
 //
 
 using System;
+using System.Globalization;\r
 using System.IO;
 using System.Text;
 using System.Xml.XPath;
@@ -838,7 +839,7 @@ namespace System.Xml
                {
                        IXmlLineInfo li = reader as IXmlLineInfo;
                        if (li != null)
-                               return String.Format ("{0} Line number = {1}, Inline position = {2}.", message, li.LineNumber, li.LinePosition);
+                               return String.Format (CultureInfo.InvariantCulture, "{0} Line number = {1}, Inline position = {2}.", message, li.LineNumber, li.LinePosition);
                        else
                                return message;
                }
index c51360b995b462df9b3629684105b59dfc724e91..899dd4b924dba9496188127829da36500bedc6bb 100755 (executable)
@@ -8,6 +8,7 @@
 //
 
 using System;
+using System.Globalization;\r
 using System.Runtime.Serialization;
 
 namespace System.Xml
@@ -88,7 +89,7 @@ namespace System.Xml
                                if (lineNumber == 0)
                                        return base.Message;
 
-                               return String.Format ("{0} Line {1}, position {2}.",
+                               return String.Format (CultureInfo.InvariantCulture, "{0} Line {1}, position {2}.",
                                                      base.Message, lineNumber, linePosition);
                        }
                }
index 46eec6f5841536a1ce7d8413569b5944deb6df78..f1b15a3bb3ee5e58b681ddef0a43ef652a11dd6b 100644 (file)
@@ -465,7 +465,7 @@ namespace System.Xml
                            NodeType != XmlNodeType.Attribute &&
                            NodeType != XmlNodeType.Document &&
                            NodeType != XmlNodeType.DocumentFragment)
-                               throw new InvalidOperationException (String.Format ("Node cannot be appended to current node " + NodeType + "."));
+                               throw new InvalidOperationException (String.Format ("Node cannot be appended to current node {0}.", NodeType));
 
                        switch (NodeType) {
                        case XmlNodeType.Attribute:
@@ -475,7 +475,7 @@ namespace System.Xml
                                        break;
                                default:
                                        throw new InvalidOperationException (String.Format (
-                                               "Cannot insert specified type of node {0} as a child of this node {0}.", 
+                                               "Cannot insert specified type of node {0} as a child of this node {1}.", 
                                                newChild.NodeType, NodeType));
                                }
                                break;
index efd222bb443837d0ecc932c62768d7e16aba75d4..2cfba61814c60128a172ef8f8ff4a7f28e0ce0ce 100644 (file)
@@ -50,7 +50,7 @@ namespace System.Xml
 \r
                        if (ch != expected) {\r
                                throw ReaderError (\r
-                                       String.Format (\r
+                                       String.Format (CultureInfo.InvariantCulture, \r
                                                "expected '{0}' ({1:X}) but found '{2}' ({3:X})",\r
                                                (char)expected,\r
                                                expected,\r
@@ -173,9 +173,9 @@ namespace System.Xml
                        int ret = -1;\r
                        if (name.Length > 0 && name [0] == '#') {\r
                                if (name [1] == 'x')\r
-                                       ret = int.Parse (name.Substring (2, name.Length - 2), NumberStyles.None & NumberStyles.AllowHexSpecifier);\r
+                                       ret = int.Parse (name.Substring (2, name.Length - 2), NumberStyles.None & NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture);\r
                                else\r
-                                       ret = int.Parse (name.Substring (1, name.Length - 1));\r
+                                       ret = int.Parse (name.Substring (1, name.Length - 1), CultureInfo.InvariantCulture);\r
                        }\r
                        return ret;\r
                }\r
index c23fedd3b8478b9e4c8f5ec349af9f77497accb9..5631647dfec5690f2b3cb96c0dffa2ddabfa8ed6 100644 (file)
@@ -19,6 +19,7 @@
 
 using System;
 using System.Collections;
+using System.Globalization;\r
 using System.IO;
 using System.Security.Policy;
 using System.Text;
@@ -1575,7 +1576,7 @@ namespace System.Xml
                                                value = (value << 4) + ch - 'a' + 10;
                                        else
                                                throw new XmlException (this as IXmlLineInfo,
-                                                       String.Format (
+                                                       String.Format (CultureInfo.InvariantCulture, 
                                                                "invalid hexadecimal digit: {0} (#x{1:X})",
                                                                (char) ch,
                                                                ch));
@@ -1588,7 +1589,7 @@ namespace System.Xml
                                                value = value * 10 + ch - '0';
                                        else
                                                throw new XmlException (this as IXmlLineInfo,
-                                                       String.Format (
+                                                       String.Format (CultureInfo.InvariantCulture, 
                                                                "invalid decimal digit: {0} (#x{1:X})",
                                                                (char) ch,
                                                                ch));
@@ -1832,7 +1833,7 @@ namespace System.Xml
                        if (target == "xml") {
                                ReadXmlDeclaration ();
                                return;
-                       } else if (target.ToLower () == "xml")
+                       } else if (target.ToLower (CultureInfo.InvariantCulture) == "xml")
                                throw new XmlException (this as IXmlLineInfo,
                                        "Not allowed processing instruction name which starts with 'X', 'M', 'L' was found.");
 
@@ -1934,7 +1935,7 @@ namespace System.Xml
                                        ReadChar ();
                        }
                        if (new string (peekChars, 2, 4) != "xml ") {
-                               if (new string (peekChars, 2, 3).ToLower () == "xml") {
+                               if (new string (peekChars, 2, 3).ToLower (CultureInfo.InvariantCulture) == "xml") {
                                        throw new XmlException (this as IXmlLineInfo,
                                                "Processing instruction name must not be character sequence 'X' 'M' 'L' with case insensitivity.");
                                }
@@ -2440,7 +2441,7 @@ namespace System.Xml
                {
                        int ch = PeekChar ();
                        if (!XmlChar.IsFirstNameChar (ch))
-                               throw new XmlException (this as IXmlLineInfo,String.Format ("a name did not start with a legal character {0} ({1})", ch, (char) ch));
+                               throw new XmlException (this as IXmlLineInfo,String.Format (CultureInfo.InvariantCulture, "a name did not start with a legal character {0} ({1})", ch, (char) ch));
 
                        nameLength = 0;
 
@@ -2461,7 +2462,7 @@ namespace System.Xml
 
                        if (ch != expected) {
                                throw new XmlException (this as IXmlLineInfo,
-                                       String.Format (
+                                       String.Format (CultureInfo.InvariantCulture, 
                                                "expected '{0}' ({1:X}) but found '{2}' ({3:X})",
                                                (char) expected,
                                                expected,
@@ -2484,7 +2485,7 @@ namespace System.Xml
                                if (i < 0x21 && XmlChar.IsWhitespace (i))
                                        continue;
                                if (c != i)
-                                       throw new XmlException (this, String.Join (String.Empty, new string [] {"Expected ", c.ToString (), ", but found " + (char) i, "[", i.ToString (), "]"}));
+                                       throw new XmlException (this, String.Format (CultureInfo.InvariantCulture, "Expected {0}, but found {1} [{2}]", c, (char) i, i));
                                break;
                        }
                }
index de4375714aa4eee29632b7e64815e2f4ee2614ba..fc1b3e94136b8eb385ca18b86928830490a7da4a 100644 (file)
@@ -10,6 +10,7 @@
 //
 using System;
 using System.Collections;
+using System.Globalization;\r
 using System.IO;
 using System.Text;
 
@@ -661,7 +662,7 @@ openElements [openElementCount - 1]).IndentingOverriden;
                                        localName = prefix;
                                        prefix = String.Empty;
                                }
-                               else if (localName.ToLower ().StartsWith ("xml"))
+                               else if (localName.ToLower (CultureInfo.InvariantCulture).StartsWith ("xml"))
                                        throw new ArgumentException ("Prefixes beginning with \"xml\" (regardless of whether the characters are uppercase, lowercase, or some combination thereof) are reserved for use by XML: " + prefix + ":" + localName);
                        }
 
@@ -906,9 +907,9 @@ openElements [openElementCount - 1]).IndentingOverriden;
                                if (pos < 0) {
                                        cachedStringBuilder.Append ("&#x");
                                        if (invalid < (char) 255)
-                                               cachedStringBuilder.Append (((int) invalid).ToString ("X02"));
+                                               cachedStringBuilder.Append (((int) invalid).ToString ("X02", CultureInfo.InvariantCulture));
                                        else
-                                               cachedStringBuilder.Append (((int) invalid).ToString ("X04"));
+                                               cachedStringBuilder.Append (((int) invalid).ToString ("X04", CultureInfo.InvariantCulture));
                                        cachedStringBuilder.Append (";");
                                }
                                else
@@ -979,7 +980,7 @@ openElements [openElementCount - 1]).IndentingOverriden;
                        }
 
                        w.Write ("&#x");
-                       w.Write (((int) ((highChar - 0xD800) * 0x400 + (lowChar - 0xDC00) + 0x10000)).ToString ("X"));
+                       w.Write (((int) ((highChar - 0xD800) * 0x400 + (lowChar - 0xDC00) + 0x10000)).ToString ("X", CultureInfo.InvariantCulture));
                        w.Write (';');
                }