XmlSchemaComplexContent.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Author: Dwivedi, Ajay kumar
  2. // [email protected]
  3. using System;
  4. using System.Xml.Serialization;
  5. namespace System.Xml.Schema
  6. {
  7. /// <summary>
  8. /// Summary description for XmlSchemaComplexContent.
  9. /// </summary>
  10. public class XmlSchemaComplexContent : XmlSchemaContentModel
  11. {
  12. private XmlSchemaContent content;
  13. private bool isMixed;
  14. private int errorCount=0;
  15. public XmlSchemaComplexContent()
  16. {}
  17. [XmlElement("restriction",typeof(XmlSchemaComplexContentRestriction),Namespace="http://www.w3.org/2001/XMLSchema")]
  18. [XmlElement("extension",typeof(XmlSchemaComplexContentExtension),Namespace="http://www.w3.org/2001/XMLSchema")]
  19. public override XmlSchemaContent Content
  20. {
  21. get{ return content; }
  22. set{ content = value; }
  23. }
  24. [System.Xml.Serialization.XmlAttribute("mixed")]
  25. public bool IsMixed
  26. {
  27. get{ return isMixed; }
  28. set{ isMixed = value; }
  29. }
  30. /// <remarks>
  31. /// 1. Content must be present
  32. /// </remarks>
  33. [MonoTODO]
  34. internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
  35. {
  36. if(Content == null)
  37. {
  38. error(h, "Content must be present in a complexContent");
  39. }
  40. else
  41. {
  42. if(Content is XmlSchemaComplexContentRestriction)
  43. {
  44. XmlSchemaComplexContentRestriction xscr = (XmlSchemaComplexContentRestriction) Content;
  45. errorCount += xscr.Compile(h,info);
  46. }
  47. else if(Content is XmlSchemaComplexContentExtension)
  48. {
  49. XmlSchemaComplexContentExtension xsce = (XmlSchemaComplexContentExtension) Content;
  50. errorCount += xsce.Compile(h,info);
  51. }
  52. else
  53. error(h,"complexContent can't have any value other than restriction or extention");
  54. }
  55. if(this.Id != null && !XmlSchemaUtil.CheckID(Id))
  56. error(h, "id must be a valid ID");
  57. return errorCount;
  58. }
  59. [MonoTODO]
  60. internal int Validate(ValidationEventHandler h)
  61. {
  62. return errorCount;
  63. }
  64. internal void error(ValidationEventHandler handle,string message)
  65. {
  66. errorCount++;
  67. ValidationHandler.RaiseValidationError(handle,this,message);
  68. }
  69. }
  70. }