XmlSchemaSimpleContent.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 XmlSchemaSimpleContent.
  9. /// </summary>
  10. public class XmlSchemaSimpleContent : XmlSchemaContentModel
  11. {
  12. private XmlSchemaContent content;
  13. private int errorCount;
  14. public XmlSchemaSimpleContent()
  15. {
  16. }
  17. [XmlElement("restriction",typeof(XmlSchemaSimpleContentRestriction),Namespace="http://www.w3.org/2001/XMLSchema")]
  18. [XmlElement("extension",typeof(XmlSchemaSimpleContentExtension),Namespace="http://www.w3.org/2001/XMLSchema")]
  19. public override XmlSchemaContent Content
  20. {
  21. get{ return content; }
  22. set{ content = value; }
  23. }
  24. ///<remarks>
  25. /// 1. Content must be present and one of restriction or extention
  26. ///</remarks>
  27. [MonoTODO]
  28. internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
  29. {
  30. if(Content == null)
  31. {
  32. error(h, "Content must be present in a simpleContent");
  33. }
  34. else
  35. {
  36. if(Content is XmlSchemaSimpleContentRestriction)
  37. {
  38. XmlSchemaSimpleContentRestriction xscr = (XmlSchemaSimpleContentRestriction) Content;
  39. errorCount += xscr.Compile(h,info);
  40. }
  41. else if(Content is XmlSchemaSimpleContentExtension)
  42. {
  43. XmlSchemaSimpleContentExtension xsce = (XmlSchemaSimpleContentExtension) Content;
  44. errorCount += xsce.Compile(h,info);
  45. }
  46. else
  47. error(h,"simpleContent can't have any value other than restriction or extention");
  48. }
  49. if(this.Id != null && !XmlSchemaUtil.CheckID(Id))
  50. error(h, "id must be a valid ID");
  51. return errorCount;
  52. }
  53. [MonoTODO]
  54. internal int Validate(ValidationEventHandler h)
  55. {
  56. return errorCount;
  57. }
  58. internal void error(ValidationEventHandler handle,string message)
  59. {
  60. ValidationHandler.RaiseValidationError(handle,this,message);
  61. }
  62. }
  63. }