2003-10-25 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
authorAtsushi Eno <atsushieno@gmail.com>
Sat, 25 Oct 2003 15:52:43 +0000 (15:52 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Sat, 25 Oct 2003 15:52:43 +0000 (15:52 -0000)
* DTDValidatingReader.cs : Now it handles whitespace entity as
  significant.
* XmlConvert.cs : As to NIST testcases, exponential support on single
  and double floating point numbers.
* XmlValidatingReader.cs : If it IsDefault, then line number and line
  position returns 0.

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

mcs/class/System.XML/System.Xml/ChangeLog
mcs/class/System.XML/System.Xml/DTDValidatingReader.cs
mcs/class/System.XML/System.Xml/XmlConvert.cs
mcs/class/System.XML/System.Xml/XmlValidatingReader.cs

index 5f698339c35e4a9dae32e75184c2fe3d1d53b22d..ef9b40c24dcb23416972725461db4ac294243501 100644 (file)
@@ -1,3 +1,12 @@
+2003-10-25  Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+       * DTDValidatingReader.cs : Now it handles whitespace entity as
+         significant.
+       * XmlConvert.cs : As to NIST testcases, exponential support on single
+         and double floating point numbers.
+       * XmlValidatingReader.cs : If it IsDefault, then line number and line
+         position returns 0.
+
 2003-10-25  Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
 
        * DTDReader.cs,
index 1ed89e73a2089a8e14665d70c429e85c319c0578..cedaf89ec0d50f8ccf31d4fbfee42c866cf54577 100644 (file)
@@ -67,6 +67,7 @@ namespace Mono.Xml
                bool isSignificantWhitespace;
                bool isWhitespace;
                bool isText;
+               bool nextMaybeSignificantWhitespace;
 
                // This field is used to get properties and to raise events.
                XmlValidatingReader validatingReader;
@@ -286,6 +287,7 @@ namespace Mono.Xml
                        isWhitespace = false;
                        isSignificantWhitespace = false;
                        isText = false;
+                       nextMaybeSignificantWhitespace = false;
 
                        bool b = ReadContent () || currentTextValue != null;
                        if (!b && this.missingIDReferences.Count > 0) {
@@ -302,6 +304,7 @@ namespace Mono.Xml
                private bool ReadContent ()
                {
                        if (nextEntityReader != null) {
+                               nextMaybeSignificantWhitespace = true;
                                if (DTD == null || DTD.EntityDecls [reader.Name] == null)
                                        throw new XmlException ("Entity '" + reader.Name + "' was not declared.");
                                entityReaderStack.Push (reader);
@@ -347,6 +350,8 @@ namespace Mono.Xml
                                return false;
                        }
 
+                       bool dontResetTextType = false;
+
                        switch (reader.NodeType) {
                        case XmlNodeType.XmlDeclaration:
                                if (GetAttribute ("standalone") == "yes")
@@ -484,10 +489,13 @@ namespace Mono.Xml
                        case XmlNodeType.SignificantWhitespace:
                                if (!isText)
                                        isSignificantWhitespace = true;
+                               dontResetTextType = true;
                                goto case XmlNodeType.Text;
                        case XmlNodeType.Text:
                                isText = true;
-                               isWhitespace = isSignificantWhitespace = false;
+                               if (!dontResetTextType) {
+                                       isWhitespace = isSignificantWhitespace = false;
+                               }
                                // If no schema specification, then skip validation.
                                if (currentAutomata == null)
                                        break;
@@ -498,7 +506,6 @@ namespace Mono.Xml
                                if (elem != null && !elem.IsMixedContent && !elem.IsAny) {
                                        HandleError (String.Format ("Current element {0} does not allow character data content.", elementStack.Peek () as string),
                                                XmlSeverityType.Error);
-                                       // FIXME: validation recovery code here.
                                        currentAutomata = previousAutomata;
                                }
                                if (validatingReader.EntityHandling == EntityHandling.ExpandEntities) {
@@ -507,6 +514,11 @@ namespace Mono.Xml
                                }
                                break;
                        case XmlNodeType.Whitespace:
+                               if (nextMaybeSignificantWhitespace) {
+                                       currentTextValue = reader.Value;
+                                       nextMaybeSignificantWhitespace = false;
+                                       goto case XmlNodeType.SignificantWhitespace;
+                               }
                                if (!isText && !isSignificantWhitespace)
                                        isWhitespace = true;
                                if (validatingReader.EntityHandling == EntityHandling.ExpandEntities) {
index b28d42eb6a66a0b9edb29c130f34704cc813a02d..78a173c39924716a746c9487fc9cd6e6e846cf9b 100755 (executable)
@@ -5,7 +5,7 @@
 //      Dwivedi, Ajay kumar (Adwiv@Yahoo.com)
 //     Gonzalo Paniagua Javier (gonzalo@ximian.com)
 //      Alan Tam Siu Lung (Tam@SiuLung.com)
-//     Atsushi Enomoto (ginga@kit.h-ho.ne.jp)
+//     Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
 //
 // (C) 2002 Ximian, Inc (http://www.ximian.com)
 //
@@ -20,9 +20,13 @@ namespace System.Xml {
 
                static string encodedColon;
                static string [] datetimeFormats;
+               static NumberStyles floatStyle;
 
                static XmlConvert ()
                {
+                       floatStyle = NumberStyles.AllowCurrencySymbol | 
+                               NumberStyles.AllowExponent | 
+                               NumberStyles.AllowDecimalPoint;
                        encodedColon = "_x003A_";
                        datetimeFormats = new string[] {
                          // dateTime
@@ -229,15 +233,15 @@ namespace System.Xml {
                
                public static Decimal ToDecimal(string s)
                {
-                       return Decimal.Parse(s, NumberFormatInfo.InvariantInfo);
+                       return Decimal.Parse(s, CultureInfo.InvariantCulture);
                }
-               
+
                public static double ToDouble(string s)
                {
                        if (s == "INF") return System.Double.PositiveInfinity;
                        if (s == "-INF") return System.Double.NegativeInfinity;
                        if (s == "NaN") return System.Double.NaN;
-                       return Double.Parse(s, CultureInfo.InvariantCulture);
+                       return Double.Parse (s, floatStyle);
                }
 
                public static Guid ToGuid(string s)
@@ -271,12 +275,12 @@ namespace System.Xml {
                        if (s == "INF") return System.Single.PositiveInfinity;
                        if (s == "-INF") return System.Single.NegativeInfinity;
                        if (s == "NaN") return System.Single.NaN;
-                       return Single.Parse(s, CultureInfo.InvariantCulture);
+                       return Single.Parse(s, floatStyle);
                }
 
                public static string ToString(Guid value)
                {
-                       return value.ToString("D",CultureInfo.InvariantCulture);
+                       return value.ToString("D", CultureInfo.InvariantCulture);
                }
 
                public static string ToString(int value)
@@ -318,7 +322,7 @@ namespace System.Xml {
 
                public static string ToString(Decimal value)
                {
-                       return value.ToString(CultureInfo.InvariantCulture);
+                       return value.ToString (CultureInfo.InvariantCulture);
                }
 
                [CLSCompliant (false)]
index ceb686fd8237048fef856f24d28d06a74d057531..6e8df197b0b06635b9f9f9a3344fb41b0b61e126 100644 (file)
@@ -125,6 +125,8 @@ namespace System.Xml {
 
                int IXmlLineInfo.LineNumber {
                        get {
+                               if (IsDefault)
+                                       return 0;
                                IXmlLineInfo info = validatingReader as IXmlLineInfo;
                                return info != null ? info.LineNumber : 0;
                        }
@@ -132,6 +134,8 @@ namespace System.Xml {
 
                int IXmlLineInfo.LinePosition {
                        get {
+                               if (IsDefault)
+                                       return 0;
                                IXmlLineInfo info = validatingReader as IXmlLineInfo;
                                return info != null ? info.LinePosition : 0;
                        }