XmlSchemaMaxInclusiveFacet.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Author: Dwivedi, Ajay kumar
  2. // [email protected]
  3. using System;
  4. using System.Xml;
  5. namespace System.Xml.Schema
  6. {
  7. /// <summary>
  8. /// Summary description for XmlSchemaMaxInclusiveFacet.
  9. /// </summary>
  10. public class XmlSchemaMaxInclusiveFacet : XmlSchemaFacet
  11. {
  12. private static string xmlname = "maxInclusive";
  13. public XmlSchemaMaxInclusiveFacet()
  14. {
  15. }
  16. internal override Facet ThisFacet {
  17. get { return Facet.maxInclusive;}
  18. }
  19. //<maxInclusive
  20. // fixed = boolean : false
  21. // id = ID
  22. // value = anySimpleType
  23. // {any attributes with non-schema namespace . . .}>
  24. // Content: (annotation?)
  25. //</maxInclusive>
  26. internal static XmlSchemaMaxInclusiveFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
  27. {
  28. XmlSchemaMaxInclusiveFacet maxi = new XmlSchemaMaxInclusiveFacet();
  29. reader.MoveToElement();
  30. if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
  31. {
  32. error(h,"Should not happen :1: XmlSchemaMaxInclusiveFacet.Read, name="+reader.Name,null);
  33. reader.Skip();
  34. return null;
  35. }
  36. maxi.LineNumber = reader.LineNumber;
  37. maxi.LinePosition = reader.LinePosition;
  38. maxi.SourceUri = reader.BaseURI;
  39. while(reader.MoveToNextAttribute())
  40. {
  41. if(reader.Name == "id")
  42. {
  43. maxi.Id = reader.Value;
  44. }
  45. else if(reader.Name == "fixed")
  46. {
  47. Exception innerex;
  48. maxi.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
  49. if(innerex != null)
  50. error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
  51. }
  52. else if(reader.Name == "value")
  53. {
  54. maxi.Value = reader.Value;
  55. }
  56. else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
  57. {
  58. error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
  59. }
  60. else
  61. {
  62. XmlSchemaUtil.ReadUnhandledAttribute(reader,maxi);
  63. }
  64. }
  65. reader.MoveToElement();
  66. if(reader.IsEmptyElement)
  67. return maxi;
  68. // Content: (annotation?)
  69. int level = 1;
  70. while(reader.ReadNextElement())
  71. {
  72. if(reader.NodeType == XmlNodeType.EndElement)
  73. {
  74. if(reader.LocalName != xmlname)
  75. error(h,"Should not happen :2: XmlSchemaMaxInclusiveFacet.Read, name="+reader.Name,null);
  76. break;
  77. }
  78. if(level <= 1 && reader.LocalName == "annotation")
  79. {
  80. level = 2; //Only one annotation
  81. XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
  82. if(annotation != null)
  83. maxi.Annotation = annotation;
  84. continue;
  85. }
  86. reader.RaiseInvalidElementError();
  87. }
  88. return maxi;
  89. }
  90. }
  91. }