2003-01-26 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
[mono.git] / mcs / class / System.XML / System.Xml / XmlSignificantWhitespace.cs
index 8999730699947a6a27228c80855886b70c59aa96..1df1a7f512ba18c87115db9ddf7c11e01fb9f5a8 100644 (file)
@@ -8,6 +8,7 @@
 //
 
 using System;
+using System.Xml.XPath;
 
 namespace System.Xml
 {
@@ -32,9 +33,19 @@ namespace System.Xml
                        get { return XmlNodeType.SignificantWhitespace; }
                }
 
+               internal override XPathNodeType XPathNodeType {
+                       get {
+                               return XPathNodeType.SignificantWhitespace;
+                       }
+               }
+               
                public override string Value {
                        get { return Data; }
-                       set {}
+                       set {
+                               if (IsValidWhitespaceChar (value) == false)
+                                       throw new ArgumentException ("Invalid whitespace characters.");
+                               base.Data = value;
+                       }
                }
 
                // Methods
@@ -49,5 +60,13 @@ namespace System.Xml
                {
                        w.WriteWhitespace (Data);
                }
+
+               private bool IsValidWhitespaceChar (string text)
+               {
+                       foreach (char c in text)
+                               if ((c != ' ') && (c != '\r') && (c != '\n') && (c != '\t'))
+                                       return false;
+                       return true;
+               }
        }
 }