XmlSchemaGroup.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Author: Dwivedi, Ajay kumar
  2. // [email protected]
  3. using System;
  4. using System.Xml.Serialization;
  5. using System.Xml;
  6. namespace System.Xml.Schema
  7. {
  8. /// <summary>
  9. /// Summary description for XmlSchemaGroup.
  10. /// </summary>
  11. public class XmlSchemaGroup : XmlSchemaAnnotated
  12. {
  13. private string name;
  14. private XmlSchemaGroupBase particle;
  15. private XmlQualifiedName qualifiedName;
  16. private int errorCount;
  17. public XmlSchemaGroup()
  18. {
  19. }
  20. [System.Xml.Serialization.XmlAttribute("name")]
  21. public string Name
  22. {
  23. get{ return name; }
  24. set{ name = value; }
  25. }
  26. [XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
  27. [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
  28. [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
  29. public XmlSchemaGroupBase Particle
  30. {
  31. get{ return particle; }
  32. set{ particle = value; }
  33. }
  34. [XmlIgnore]
  35. internal XmlQualifiedName QualifiedName
  36. {
  37. get{ return qualifiedName;}
  38. }
  39. // 1. name must be present
  40. [MonoTODO]
  41. internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
  42. {
  43. if(Name == null)
  44. error(h,"Required attribute name must be present");
  45. else if(!XmlSchemaUtil.CheckNCName(this.name))
  46. error(h,"attribute name must be NCName");
  47. else
  48. qualifiedName = new XmlQualifiedName(Name,info.targetNS);
  49. if(Particle == null)
  50. {
  51. error(h,"Particle is required");
  52. }
  53. else if(Particle is XmlSchemaChoice)
  54. {
  55. errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);
  56. }
  57. else if(Particle is XmlSchemaSequence)
  58. {
  59. errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);
  60. }
  61. else if(Particle is XmlSchemaAll)
  62. {
  63. errorCount += ((XmlSchemaAll)Particle).Compile(h,info);
  64. }
  65. else
  66. {
  67. error(h,"only all,choice or sequence are allowed");
  68. }
  69. if(this.Id != null && !XmlSchemaUtil.CheckID(Id))
  70. error(h, "id must be a valid ID");
  71. return errorCount;
  72. }
  73. [MonoTODO]
  74. internal int Validate(ValidationEventHandler h)
  75. {
  76. return errorCount;
  77. }
  78. internal void error(ValidationEventHandler handle,string message)
  79. {
  80. errorCount++;
  81. ValidationHandler.RaiseValidationError(handle,this,message);
  82. }
  83. }
  84. }