2 // System.Xml.XmlConvert
5 // Dwivedi, Ajay kumar (Adwiv@Yahoo.com)
6 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // Alan Tam Siu Lung (Tam@SiuLung.com)
8 // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
10 // (C) 2002 Ximian, Inc (http://www.ximian.com)
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 using System.Globalization;
37 using System.Xml.Schema;
39 namespace System.Xml {
41 public class XmlConvert {
43 const string encodedColon = "_x003A_";
44 const NumberStyles floatStyle = NumberStyles.AllowCurrencySymbol |
45 NumberStyles.AllowExponent |
46 NumberStyles.AllowDecimalPoint |
47 NumberStyles.AllowLeadingSign |
48 NumberStyles.AllowLeadingWhite |
49 NumberStyles.AllowTrailingWhite;
51 const NumberStyles integerStyle = NumberStyles.Integer |
52 NumberStyles.AllowLeadingWhite |
53 NumberStyles.AllowTrailingWhite;
55 static readonly string [] datetimeFormats = {
58 "yyyy-MM-ddTHH:mm:sszzz",
59 "yyyy-MM-ddTHH:mm:ss.FFFFFFFzzz",
60 "yyyy-MM-ddTHH:mm:ssZ",
61 "yyyy-MM-ddTHH:mm:ss.FFFFFFFZ",
62 "yyyy-MM-ddTHH:mm:ss",
63 "yyyy-MM-ddTHH:mm:ss.FFFFFFF",
67 "HH:mm:ss.FFFFFFFzzz",
70 #else // it is not required in trunk but should make it easy to backport...
71 "yyyy-MM-ddTHH:mm:sszzz",
72 "yyyy-MM-ddTHH:mm:ss.fzzz",
73 "yyyy-MM-ddTHH:mm:ss.ffzzz",
74 "yyyy-MM-ddTHH:mm:ss.fffzzz",
75 "yyyy-MM-ddTHH:mm:ss.ffffzzz",
76 "yyyy-MM-ddTHH:mm:ss.fffffzzz",
77 "yyyy-MM-ddTHH:mm:ss.ffffffzzz",
78 "yyyy-MM-ddTHH:mm:ss.fffffffzzz",
79 "yyyy-MM-ddTHH:mm:ssZ",
80 "yyyy-MM-ddTHH:mm:ss.fZ",
81 "yyyy-MM-ddTHH:mm:ss.ffZ",
82 "yyyy-MM-ddTHH:mm:ss.fffZ",
83 "yyyy-MM-ddTHH:mm:ss.ffffZ",
84 "yyyy-MM-ddTHH:mm:ss.fffffZ",
85 "yyyy-MM-ddTHH:mm:ss.ffffffZ",
86 "yyyy-MM-ddTHH:mm:ss.fffffffZ",
87 "yyyy-MM-ddTHH:mm:ss",
88 "yyyy-MM-ddTHH:mm:ss.f",
89 "yyyy-MM-ddTHH:mm:ss.ff",
90 "yyyy-MM-ddTHH:mm:ss.fff",
91 "yyyy-MM-ddTHH:mm:ss.ffff",
92 "yyyy-MM-ddTHH:mm:ss.fffff",
93 "yyyy-MM-ddTHH:mm:ss.ffffff",
94 "yyyy-MM-ddTHH:mm:ss.fffffff",
110 "HH:mm:ss.ffffffzzz",
111 "HH:mm:ss.fffffffzzz",
144 static readonly string [] defaultDateTimeFormats = new string [] {
145 "yyyy-MM-ddTHH:mm:ss", // dateTime(1)
146 "yyyy-MM-ddTHH:mm:ss.FFFFFFF", // dateTime(2)
147 "yyyy-MM-dd", // date
149 "yyyy-MM", // gYearMonth
151 "--MM-dd", // gMonthDay
155 static readonly string [] roundtripDateTimeFormats;
156 static readonly string [] localDateTimeFormats;
157 static readonly string [] utcDateTimeFormats;
158 static readonly string [] unspecifiedDateTimeFormats;
162 int l = defaultDateTimeFormats.Length;
163 roundtripDateTimeFormats = new string [l * 2];
164 localDateTimeFormats = new string [l * 2];
165 utcDateTimeFormats = new string [l * 3];
166 unspecifiedDateTimeFormats = new string [l * 5];
167 for (int i = 0; i < l; i++) {
168 string s = defaultDateTimeFormats [i];
170 localDateTimeFormats [i * 2] = s + (s [s.Length - 1] == 's' || s [s.Length - 1] == 'F' ? "zzz" : String.Empty);
171 localDateTimeFormats [i * 2 + 1] = z;
172 roundtripDateTimeFormats [i * 2] = s + 'K';
173 roundtripDateTimeFormats [i * 2 + 1] = z;
174 utcDateTimeFormats [i * 3] = s;
175 utcDateTimeFormats [i * 3 + 1] = z;
176 utcDateTimeFormats [i * 3 + 2] = s + "zzz";
177 unspecifiedDateTimeFormats [i * 5] = s;
178 unspecifiedDateTimeFormats [i * 5 + 1] = z;
179 unspecifiedDateTimeFormats [i * 5 + 2] = localDateTimeFormats [i];
180 unspecifiedDateTimeFormats [i * 5 + 3] = roundtripDateTimeFormats [i];
181 unspecifiedDateTimeFormats [i * 5 + 4] = utcDateTimeFormats [i];
185 static DateTimeStyles _defaultStyle = DateTimeStyles.AllowLeadingWhite | DateTimeStyles.AllowTrailingWhite;
190 private static string TryDecoding (string s)
192 if (s == null || s.Length < 6)
197 c = (char) Int32.Parse (s.Substring (1, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
199 return s [0] + DecodeName (s.Substring (1));
203 return c.ToString ();
204 return c + DecodeName (s.Substring (6));
207 public static string DecodeName (string name)
209 if (name == null || name.Length == 0)
212 int pos = name.IndexOf ('_');
213 if (pos == -1 || pos + 6 >= name.Length)
216 if ((name [pos + 1] != 'X' && name [pos + 1] != 'x') || name [pos + 6] != '_')
217 return name [0] + DecodeName (name.Substring (1));
219 return name.Substring (0, pos) + TryDecoding (name.Substring (pos + 1));
222 public static string EncodeLocalName (string name)
227 string encoded = EncodeName (name);
228 int pos = encoded.IndexOf (':');
231 return encoded.Replace (":", encodedColon);
234 internal static bool IsInvalid (char c, bool firstOnlyLetter)
236 if (c == ':') // Special case. allowed in EncodeName, but encoded in EncodeLocalName
240 return !XmlChar.IsFirstNameChar (c);
242 return !XmlChar.IsNameChar (c);
245 private static string EncodeName (string name, bool nmtoken)
247 if (name == null || name.Length == 0)
250 StringBuilder sb = new StringBuilder ();
251 int length = name.Length;
252 for (int i = 0; i < length; i++) {
254 if (IsInvalid (c, i == 0 && !nmtoken))
255 sb.AppendFormat ("_x{0:X4}_", (int) c);
256 else if (c == '_' && i + 6 < length && name [i+1] == 'x' && name [i + 6] == '_')
257 sb.Append ("_x005F_");
261 return sb.ToString ();
264 public static string EncodeName (string name)
266 return EncodeName (name, false);
269 public static string EncodeNmToken (string name)
271 if (name == String.Empty)
272 throw new XmlException ("Invalid NmToken: ''");
273 return EncodeName (name, true);
276 // {true, false, 1, 0}
277 public static bool ToBoolean(string s)
279 s = s.Trim (XmlChar.WhitespaceChars);
291 throw new FormatException(s + " is not a valid boolean value");
295 // LAMESPEC: It has been documented as public, but is marked as internal.
296 internal static string ToBinHexString (byte [] buffer)
298 StringWriter w = new StringWriter ();
299 WriteBinHex (buffer, 0, buffer.Length, w);
300 return w.ToString ();
303 internal static void WriteBinHex (byte [] buffer, int index, int count, TextWriter w)
306 throw new ArgumentNullException ("buffer");
308 throw new ArgumentOutOfRangeException (
312 "index must be non negative integer.");
315 throw new ArgumentOutOfRangeException (
319 "count must be non negative integer.");
321 if (buffer.Length < index + count)
322 throw new ArgumentOutOfRangeException ("index and count must be smaller than the length of the buffer.");
324 // Copied from XmlTextWriter.WriteBinHex ()
325 int end = index + count;
326 for (int i = index; i < end; i++) {
327 int val = buffer [i];
331 w.Write ((char) (high + 55));
333 w.Write ((char) (high + 0x30));
335 w.Write ((char) (low + 55));
337 w.Write ((char) (low + 0x30));
341 public static byte ToByte(string s)
343 return Byte.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture);
346 public static char ToChar(string s)
349 return Char.Parse(s);
352 throw new ArgumentNullException ("s");
355 throw new FormatException ("String contain more than one char");
364 public static DateTime ToDateTime (string s)
366 return ToDateTime (s, datetimeFormats);
370 public static DateTime ToDateTime (string s, XmlDateTimeSerializationMode dateTimeOption)
373 switch (dateTimeOption) {
374 case XmlDateTimeSerializationMode.Local:
375 dt = ToDateTime (s, localDateTimeFormats);
376 return new DateTime (dt.Ticks, DateTimeKind.Local);
377 case XmlDateTimeSerializationMode.RoundtripKind:
378 return ToDateTime (s, roundtripDateTimeFormats, _defaultStyle | DateTimeStyles.RoundtripKind);
379 case XmlDateTimeSerializationMode.Utc:
380 dt = ToDateTime (s, utcDateTimeFormats);
381 return new DateTime (dt.Ticks, DateTimeKind.Utc);
382 case XmlDateTimeSerializationMode.Unspecified:
383 return ToDateTime (s, unspecifiedDateTimeFormats);
385 return ToDateTime (s, defaultDateTimeFormats);
389 public static DateTime ToDateTime(string s, string format)
391 //DateTimeFormatInfo d = new DateTimeFormatInfo();
392 //d.FullDateTimePattern = format;
393 //return DateTime.Parse(s, d);
394 DateTimeStyles style = DateTimeStyles.AllowLeadingWhite |
395 DateTimeStyles.AllowTrailingWhite;
396 return DateTime.ParseExact (s, format, DateTimeFormatInfo.InvariantInfo, style);
399 public static DateTime ToDateTime(string s, string[] formats)
401 return ToDateTime (s, formats, _defaultStyle);
404 private static DateTime ToDateTime (string s, string [] formats, DateTimeStyles style)
407 return DateTime.ParseExact (s, formats, DateTimeFormatInfo.InvariantInfo, style);
408 } catch (ArgumentOutOfRangeException) {
409 return DateTime.MinValue;
413 public static Decimal ToDecimal(string s)
415 return Decimal.Parse(s, CultureInfo.InvariantCulture);
418 public static double ToDouble(string s)
421 throw new ArgumentNullException();
423 float f = TryParseStringFloatConstants (s);
427 return Double.Parse (s, floatStyle, CultureInfo.InvariantCulture);
430 static float TryParseStringFloatConstants (string s)
433 while (sidx < s.Length && Char.IsWhiteSpace (s [sidx]))
435 if (sidx == s.Length)
436 throw new FormatException ();
437 int sEndPos = s.Length - 1;
438 while (Char.IsWhiteSpace (s [sEndPos]))
441 if (TryParseStringConstant ("NaN", s, sidx, sEndPos))
443 if (TryParseStringConstant ("INF", s, sidx, sEndPos))
444 return Single.PositiveInfinity;
445 if (TryParseStringConstant ("-INF", s, sidx, sEndPos))
446 return Single.NegativeInfinity;
447 // Handle these here because Single.Parse("Infinity") is invalid while XmlConvert.ToSingle("Infinity") is valid.
448 if (TryParseStringConstant ("Infinity", s, sidx, sEndPos))
449 return Single.PositiveInfinity;
450 if (TryParseStringConstant ("-Infinity", s, sidx, sEndPos))
451 return Single.NegativeInfinity;
455 static bool TryParseStringConstant (string format, string s, int start, int end)
457 return end - start + 1 == format.Length && String.CompareOrdinal (format, 0, s, start, format.Length) == 0;
460 public static Guid ToGuid (string s)
464 } catch (FormatException ex) {
465 throw new FormatException (String.Format ("Invalid Guid input '{0}'", ex.InnerException));
469 public static short ToInt16(string s)
471 return Int16.Parse (s, integerStyle, CultureInfo.InvariantCulture);
474 public static int ToInt32(string s)
476 return Int32.Parse (s, integerStyle, CultureInfo.InvariantCulture);
479 public static long ToInt64(string s)
481 return Int64.Parse (s, integerStyle, CultureInfo.InvariantCulture);
484 [CLSCompliant (false)]
485 public static SByte ToSByte(string s)
487 return SByte.Parse(s, integerStyle, CultureInfo.InvariantCulture);
490 public static float ToSingle(string s)
493 throw new ArgumentNullException();
495 float f = TryParseStringFloatConstants (s);
499 return Single.Parse(s, floatStyle, CultureInfo.InvariantCulture);
502 public static string ToString(Guid value)
504 return value.ToString("D", CultureInfo.InvariantCulture);
507 public static string ToString(int value)
509 return value.ToString(CultureInfo.InvariantCulture);
512 public static string ToString(short value)
514 return value.ToString(CultureInfo.InvariantCulture);
517 public static string ToString(byte value)
519 return value.ToString(CultureInfo.InvariantCulture);
522 public static string ToString(long value)
524 return value.ToString(CultureInfo.InvariantCulture);
527 public static string ToString(char value)
529 return value.ToString(CultureInfo.InvariantCulture);
532 public static string ToString(bool value)
534 if (value) return "true";
538 [CLSCompliant (false)]
539 public static string ToString(SByte value)
541 return value.ToString(CultureInfo.InvariantCulture);
544 public static string ToString(Decimal value)
546 return value.ToString (CultureInfo.InvariantCulture);
549 [CLSCompliant (false)]
550 public static string ToString(UInt64 value)
552 return value.ToString(CultureInfo.InvariantCulture);
555 public static string ToString (TimeSpan value)
557 if (value == TimeSpan.Zero)
560 StringBuilder builder = new StringBuilder ();
561 if (value.Ticks < 0) {
562 if (value == TimeSpan.MinValue)
563 return "-P10675199DT2H48M5.4775808S"; // There's one fewer tick on the positive side, so we cannot Negate this value; just hard-code it
564 builder.Append ('-');
565 value = value.Negate ();
567 builder.Append ('P');
569 builder.Append (value.Days).Append ('D');
570 long ticks = value.Ticks % TimeSpan.TicksPerMillisecond;
571 if (value.Hours > 0 || value.Minutes > 0 || value.Seconds > 0 || value.Milliseconds > 0 || ticks > 0) {
574 builder.Append (value.Hours).Append ('H');
575 if (value.Minutes > 0)
576 builder.Append (value.Minutes).Append ('M');
577 if (value.Seconds > 0 || value.Milliseconds > 0 || ticks > 0) {
578 builder.Append (value.Seconds);
579 bool trimZero = true;
581 builder.Append ('.').AppendFormat ("{0:0000000}", value.Ticks % TimeSpan.TicksPerSecond);
582 else if (value.Milliseconds > 0)
583 builder.Append ('.').AppendFormat ("{0:000}", value.Milliseconds);
587 while (builder [builder.Length - 1] == '0')
588 builder.Remove (builder.Length - 1, 1);
590 builder.Append ('S');
593 return builder.ToString ();
596 public static string ToString(double value)
598 if (Double.IsNegativeInfinity(value)) return "-INF";
599 if (Double.IsPositiveInfinity(value)) return "INF";
600 if (Double.IsNaN(value)) return "NaN";
601 return value.ToString("R", CultureInfo.InvariantCulture);
604 public static string ToString(float value)
606 if (Single.IsNegativeInfinity(value)) return "-INF";
607 if (Single.IsPositiveInfinity(value)) return "INF";
608 if (Single.IsNaN(value)) return "NaN";
609 return value.ToString("R", CultureInfo.InvariantCulture);
612 [CLSCompliant (false)]
613 public static string ToString(UInt32 value)
615 return value.ToString(CultureInfo.InvariantCulture);
618 [CLSCompliant (false)]
619 public static string ToString(UInt16 value)
621 return value.ToString(CultureInfo.InvariantCulture);
627 public static string ToString (DateTime value)
629 return value.ToString ("yyyy-MM-ddTHH:mm:ss.fffffffzzz", CultureInfo.InvariantCulture);
633 public static string ToString (DateTime value, XmlDateTimeSerializationMode dateTimeOption)
635 // Unlike usual DateTime formatting, it preserves
636 // MaxValue/MinValue as is.
637 switch (dateTimeOption) {
638 case XmlDateTimeSerializationMode.Local:
639 return (value == DateTime.MinValue ? DateTime.MinValue : value == DateTime.MaxValue ? value : value.ToLocalTime ()).ToString (
640 "yyyy-MM-ddTHH:mm:ss.FFFFFFFzzz",
641 CultureInfo.InvariantCulture);
642 case XmlDateTimeSerializationMode.RoundtripKind:
643 return value.ToString (
644 "yyyy-MM-ddTHH:mm:ss.FFFFFFFK",
645 CultureInfo.InvariantCulture);
647 return value.ToString (
648 "yyyy-MM-ddTHH:mm:ss.FFFFFFFzzz",
649 CultureInfo.InvariantCulture);
650 case XmlDateTimeSerializationMode.Utc:
651 return (value == DateTime.MinValue ? DateTime.MinValue : value == DateTime.MaxValue ? value : value.ToUniversalTime ()).ToString (
652 "yyyy-MM-ddTHH:mm:ss.FFFFFFFZ",
653 CultureInfo.InvariantCulture);
654 case XmlDateTimeSerializationMode.Unspecified:
655 return value.ToString (
656 "yyyy-MM-ddTHH:mm:ss.FFFFFFF",
657 CultureInfo.InvariantCulture);
662 public static string ToString(DateTime value, string format)
664 return value.ToString(format, CultureInfo.InvariantCulture);
667 public static TimeSpan ToTimeSpan(string s)
669 s = s.Trim (XmlChar.WhitespaceChars);
671 throw new FormatException ("Invalid format string for duration schema datatype.");
676 bool minusValue = (start == 1);
678 if (s [start] != 'P')
679 throw new FormatException ("Invalid format string for duration schema datatype.");
689 int parsedDigits = 0;
694 while (i < s.Length) {
702 for (; i < s.Length; i++)
703 if (s [i] < '0' || '9' < s [i])
706 parsedDigits = i - start;
707 int value = int.Parse (s.Substring (start, i - start), CultureInfo.InvariantCulture);
708 if (parseStep == 7) {
709 // adjust to 7 digits so that it makes sense as millisecond digits
710 for (; parsedDigits > 7; parsedDigits--)
712 for (; parsedDigits < 7; parsedDigits++)
725 days += 365 * (value / 12) + 30 * (value % 12);
727 } else if (isTime && parseStep < 6) {
743 if (!isTime || parseStep > 4)
753 if (!isTime || parseStep > 7)
774 throw new FormatException ("Invalid format string for duration schema datatype.");
775 TimeSpan ts = new TimeSpan (days, hours, minutes, seconds);
777 return TimeSpan.FromTicks (- (ts.Ticks + ticks));
779 return TimeSpan.FromTicks (ts.Ticks + ticks);
782 [CLSCompliant (false)]
783 public static UInt16 ToUInt16(string s)
785 return UInt16.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture);
788 [CLSCompliant (false)]
789 public static UInt32 ToUInt32(string s)
791 return UInt32.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture);
794 [CLSCompliant (false)]
795 public static UInt64 ToUInt64(string s)
797 return UInt64.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture);
800 public static string VerifyName (string name)
802 if (name == null || name.Length == 0)
803 throw new ArgumentNullException("name");
805 if (!XmlChar.IsName (name))
806 throw new XmlException("'" + name + "' is not a valid XML Name");
811 public static string VerifyNCName (string name)
813 if (name == null || name.Length == 0)
814 throw new ArgumentNullException("name");
816 if (!XmlChar.IsNCName (name))
817 throw new XmlException ("'" + name + "' is not a valid XML NCName");
821 public static string VerifyTOKEN (string token)
824 throw new ArgumentNullException("token");
826 if (token.Length == 0)
829 if (XmlChar.IsWhitespace (token [0]) ||
830 XmlChar.IsWhitespace (token [token.Length - 1]))
831 throw new XmlException ("Whitespace characters (#xA, #xD, #x9, #x20) are not allowed as leading or trailing whitespaces of xs:token.");
833 for (int i = 0; i < token.Length; i++)
834 if (XmlChar.IsWhitespace (token [i]) && token [i] != ' ')
835 throw new XmlException ("Either #xA, #xD or #x9 are not allowed inside xs:token.");
841 public static string VerifyNMTOKEN (string name)
843 internal static string VerifyNMTOKEN (string name)
847 throw new ArgumentNullException("name");
849 if (!XmlChar.IsNmToken (name))
850 throw new XmlException("'" + name + "' is not a valid XML NMTOKEN");
855 // It is documented as public method, but in fact it is not.
856 internal static byte [] FromBinHexString (string s)
858 char [] chars = s.ToCharArray ();
859 byte [] bytes = new byte [chars.Length / 2 + chars.Length % 2];
860 FromBinHexString (chars, 0, chars.Length, bytes);
864 internal static int FromBinHexString (char [] chars, int offset, int charLength, byte [] buffer)
866 int bufIndex = offset;
867 for (int i = 0; i < charLength - 1; i += 2) {
868 buffer [bufIndex] = (chars [i] > '9' ?
869 (byte) (chars [i] - 'A' + 10) :
870 (byte) (chars [i] - '0'));
871 buffer [bufIndex] <<= 4;
872 buffer [bufIndex] += chars [i + 1] > '9' ?
873 (byte) (chars [i + 1] - 'A' + 10) :
874 (byte) (chars [i + 1] - '0');
877 if (charLength %2 != 0)
878 buffer [bufIndex++] = (byte)
879 ((chars [charLength - 1] > '9' ?
880 (byte) (chars [charLength - 1] - 'A' + 10) :
881 (byte) (chars [charLength - 1] - '0'))
884 return bufIndex - offset;
887 #if NET_2_0 // actually NET_3_5
890 public static DateTimeOffset ToDateTimeOffset (string s)
892 return ToDateTimeOffset (s, datetimeFormats);
895 public static DateTimeOffset ToDateTimeOffset (string s, string format)
897 return DateTimeOffset.ParseExact (s, format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
900 public static DateTimeOffset ToDateTimeOffset (string s, string [] formats)
902 DateTimeStyles style = DateTimeStyles.AllowLeadingWhite |
903 DateTimeStyles.AllowTrailingWhite |
904 DateTimeStyles.AssumeUniversal;
905 return DateTimeOffset.ParseExact (s, formats, CultureInfo.InvariantCulture, style);
908 public static string ToString (DateTimeOffset value)
910 return ToString (value, "yyyy-MM-ddTHH:mm:ss.FFFFFFFzzz");
913 public static string ToString (DateTimeOffset value, string format)
915 return value.ToString (format, CultureInfo.InvariantCulture);
919 // it is used only from 2.1 System.Xml.Serialization.dll from
920 // MS Silverlight SDK. We don't use it so far.
921 internal static Uri ToUri (string s)
923 return new Uri (s, UriKind.RelativeOrAbsolute);
929 public static bool IsNCNameChar (char ch)
931 throw new NotImplementedException ();
934 public static bool IsPublicIdChar (char ch)
936 throw new NotImplementedException ();
939 public static bool IsStartNCNameChar (char ch)
941 throw new NotImplementedException ();
944 public static bool IsWhitespaceChar (char ch)
946 throw new NotImplementedException ();
949 public static bool IsXmlChar (char ch)
951 throw new NotImplementedException ();
954 public static bool IsXmlSurrogatePair (char lowChar, char highChar)
956 throw new NotImplementedException ();
959 public static string VerifyPublicId (string publicId)
961 throw new NotImplementedException ();
964 public static string VerifyWhitespace (string content)
966 throw new NotImplementedException ();
969 public static string VerifyXmlChars (string content)
971 throw new NotImplementedException ();