XmlSchemaChoice.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 XmlSchemaAll.
  9. /// </summary>
  10. public class XmlSchemaChoice : XmlSchemaGroupBase
  11. {
  12. private XmlSchemaObjectCollection items;
  13. private int errorCount=0;
  14. public XmlSchemaChoice()
  15. {
  16. items = new XmlSchemaObjectCollection();
  17. }
  18. [XmlElement("element",typeof(XmlSchemaElement),Namespace="http://www.w3.org/2001/XMLSchema")]
  19. [XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
  20. [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
  21. [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
  22. [XmlElement("any",typeof(XmlSchemaAny),Namespace="http://www.w3.org/2001/XMLSchema")]
  23. public override XmlSchemaObjectCollection Items
  24. {
  25. get{ return items; }
  26. }
  27. [MonoTODO]
  28. internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
  29. {
  30. foreach(XmlSchemaObject obj in Items)
  31. {
  32. if(obj is XmlSchemaElement)
  33. {
  34. errorCount += ((XmlSchemaElement)obj).Compile(h,info);
  35. }
  36. else if(obj is XmlSchemaGroupRef)
  37. {
  38. errorCount += ((XmlSchemaGroupRef)obj).Compile(h,info);
  39. }
  40. else if(obj is XmlSchemaChoice)
  41. {
  42. errorCount += ((XmlSchemaChoice)obj).Compile(h,info);
  43. }
  44. else if(obj is XmlSchemaSequence)
  45. {
  46. errorCount += ((XmlSchemaSequence)obj).Compile(h,info);
  47. }
  48. else if(obj is XmlSchemaAny)
  49. {
  50. errorCount += ((XmlSchemaAny)obj).Compile(h,info);
  51. }
  52. }
  53. return errorCount;
  54. }
  55. [MonoTODO]
  56. internal int Validate(ValidationEventHandler h)
  57. {
  58. return errorCount;
  59. }
  60. internal void error(ValidationEventHandler handle,string message)
  61. {
  62. errorCount++;
  63. ValidationHandler.RaiseValidationError(handle,this,message);
  64. }
  65. }
  66. }