2
0

XmlSchemaAttributeGroup.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 XmlSchemaAttributeGroup.
  10. /// </summary>
  11. public class XmlSchemaAttributeGroup : XmlSchemaAnnotated
  12. {
  13. private XmlSchemaAnyAttribute any;
  14. private XmlSchemaObjectCollection attributes;
  15. private string name;
  16. private XmlSchemaAttributeGroup redefined;
  17. private XmlQualifiedName qualifiedName;
  18. private int errorCount;
  19. public XmlSchemaAttributeGroup()
  20. {
  21. attributes = new XmlSchemaObjectCollection();
  22. }
  23. [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
  24. public XmlSchemaAnyAttribute AnyAttribute
  25. {
  26. get{ return any;}
  27. set{ any = value;}
  28. }
  29. [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
  30. [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
  31. public XmlSchemaObjectCollection Attributes
  32. {
  33. get{ return attributes;}
  34. }
  35. [System.Xml.Serialization.XmlAttribute("name")]
  36. public string Name
  37. {
  38. get{ return name;}
  39. set{ name = value;}
  40. }
  41. //Undocumented property
  42. [XmlIgnore]
  43. public XmlSchemaAttributeGroup RedefinedAttributeGroup
  44. {
  45. get{ return redefined;}
  46. }
  47. [XmlIgnore]
  48. internal XmlQualifiedName QualifiedName
  49. {
  50. get{ return qualifiedName;}
  51. }
  52. /// <remarks>
  53. /// An Attribute group can only be defined as a child of XmlSchema or in XmlSchemaRedefine.
  54. /// The other attributeGroup has type XmlSchemaAttributeGroupRef.
  55. /// 1. Name must be present
  56. /// </remarks>
  57. [MonoTODO]
  58. internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
  59. {
  60. errorCount = 0;
  61. if(this.Name == null) //1
  62. error(h,"Name is required in top level simpletype");
  63. else if(!XmlSchemaUtil.CheckNCName(this.Name)) // b.1.2
  64. error(h,"name attribute of a simpleType must be NCName");
  65. else
  66. this.qualifiedName = new XmlQualifiedName(this.Name,info.targetNS);
  67. if(this.AnyAttribute != null)
  68. {
  69. errorCount += this.AnyAttribute.Compile(h,info);
  70. }
  71. foreach(XmlSchemaObject obj in Attributes)
  72. {
  73. if(obj is XmlSchemaAttribute)
  74. {
  75. XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
  76. errorCount += attr.Compile(h, info);
  77. }
  78. else if(obj is XmlSchemaAttributeGroupRef)
  79. {
  80. XmlSchemaAttributeGroupRef gref = (XmlSchemaAttributeGroupRef) obj;
  81. errorCount += gref.Compile(h, info);
  82. }
  83. else
  84. {
  85. error(h,"invalid type of object in Attributes property");
  86. }
  87. }
  88. return errorCount;
  89. }
  90. [MonoTODO]
  91. internal int Validate(ValidationEventHandler h)
  92. {
  93. return errorCount;
  94. }
  95. internal void error(ValidationEventHandler handle,string message)
  96. {
  97. this.errorCount++;
  98. ValidationHandler.RaiseValidationError(handle,this,message);
  99. }
  100. }
  101. }