XmlSchemaComplexContentExtension.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Author: Dwivedi, Ajay kumar
  2. // [email protected]
  3. using System;
  4. using System.Xml;
  5. using System.Xml.Serialization;
  6. namespace System.Xml.Schema
  7. {
  8. /// <summary>
  9. /// Summary description for XmlSchemaComplexContentExtension.
  10. /// </summary>
  11. public class XmlSchemaComplexContentExtension : XmlSchemaContent
  12. {
  13. private XmlSchemaAnyAttribute any;
  14. private XmlSchemaObjectCollection attributes;
  15. private XmlQualifiedName baseTypeName;
  16. private XmlSchemaParticle particle;
  17. private int errorCount = 0;
  18. public XmlSchemaComplexContentExtension()
  19. {
  20. attributes = new XmlSchemaObjectCollection();
  21. baseTypeName = XmlQualifiedName.Empty;
  22. }
  23. [System.Xml.Serialization.XmlAttribute("base")]
  24. public XmlQualifiedName BaseTypeName
  25. {
  26. get{ return baseTypeName; }
  27. set{ baseTypeName = value; }
  28. }
  29. [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
  30. public XmlSchemaAnyAttribute AnyAttribute
  31. {
  32. get{ return any; }
  33. set{ any = value;}
  34. }
  35. [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
  36. [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
  37. public XmlSchemaObjectCollection Attributes
  38. {
  39. get{ return attributes; }
  40. }
  41. [XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
  42. [XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
  43. [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
  44. [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
  45. public XmlSchemaParticle Particle
  46. {
  47. get{ return particle; }
  48. set{ particle = value; }
  49. }
  50. /// <remarks>
  51. /// </remarks>
  52. [MonoTODO]
  53. internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
  54. {
  55. if(BaseTypeName == null || BaseTypeName.IsEmpty)
  56. {
  57. error(h, "base must be present and a QName");
  58. }
  59. if(this.AnyAttribute != null)
  60. {
  61. errorCount += AnyAttribute.Compile(h,info);
  62. }
  63. foreach(XmlSchemaObject obj in Attributes)
  64. {
  65. if(obj is XmlSchemaAttribute)
  66. {
  67. XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
  68. errorCount += attr.Compile(h,info);
  69. }
  70. else if(obj is XmlSchemaAttributeGroupRef)
  71. {
  72. XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;
  73. errorCount += atgrp.Compile(h,info);
  74. }
  75. else
  76. error(h,"object is not valid in this place");
  77. }
  78. if(Particle != null)
  79. {
  80. if(Particle is XmlSchemaGroupRef)
  81. {
  82. errorCount += ((XmlSchemaGroupRef)Particle).Compile(h,info);
  83. }
  84. else if(Particle is XmlSchemaAll)
  85. {
  86. errorCount += ((XmlSchemaAll)Particle).Compile(h,info);
  87. }
  88. else if(Particle is XmlSchemaChoice)
  89. {
  90. errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);
  91. }
  92. else if(Particle is XmlSchemaSequence)
  93. {
  94. errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);
  95. }
  96. }
  97. if(this.Id != null && !XmlSchemaUtil.CheckID(Id))
  98. error(h, "id must be a valid ID");
  99. return errorCount;
  100. }
  101. [MonoTODO]
  102. internal int Validate(ValidationEventHandler h)
  103. {
  104. return errorCount;
  105. }
  106. internal void error(ValidationEventHandler handle,string message)
  107. {
  108. errorCount++;
  109. ValidationHandler.RaiseValidationError(handle,this,message);
  110. }
  111. }
  112. }