XmlSchemaUtil.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Xml;
  3. namespace System.Xml.Schema
  4. {
  5. /// <summary>
  6. /// Summary description for XmlSchemaUtil.
  7. /// </summary>
  8. public class XmlSchemaUtil
  9. {
  10. private XmlSchemaUtil()
  11. {}
  12. [MonoTODO]
  13. public static bool CheckID(string id)
  14. {
  15. //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#ID
  16. // 1. ID must be a NCName
  17. // 2. ID must be unique in the schema
  18. if(!CheckNCName(id))
  19. return false;
  20. //If !unique
  21. return true;
  22. }
  23. [MonoTODO]
  24. public static bool CheckAnyUri(string uri)
  25. {
  26. //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#anyURI
  27. return true;
  28. }
  29. public static bool CheckToken(string token)
  30. {
  31. //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#token
  32. return true;
  33. }
  34. public static bool CheckLanguage(string lang)
  35. {
  36. //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#language
  37. return true;
  38. }
  39. public static bool CheckNCName(string name)
  40. {
  41. //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#NCName
  42. try
  43. {
  44. XmlConvert.VerifyNCName(name);
  45. return true;
  46. }
  47. catch(Exception ex)
  48. {
  49. return false;
  50. }
  51. }
  52. public static string[] SplitList(string ns)
  53. {
  54. return ns.Split(new char[]{' '});
  55. }
  56. // To Be Removed
  57. public static XmlQualifiedName GetRandomQName()
  58. {
  59. return new XmlQualifiedName(new Random().Next(int.MaxValue).ToString());
  60. }
  61. }
  62. }