XmlSchemaTotalDigitsFacet.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 XmlSchemaTotalDigitsFacet.
  9. /// </summary>
  10. public class XmlSchemaTotalDigitsFacet : XmlSchemaNumericFacet
  11. {
  12. const string xmlname = "totalDigits";
  13. public XmlSchemaTotalDigitsFacet()
  14. {
  15. }
  16. internal override Facet ThisFacet {
  17. get { return Facet.totalDigits;}
  18. }
  19. //<totalDigits
  20. // fixed = boolean : false
  21. // id = ID
  22. // value = positiveInteger
  23. // {any attributes with non-schema namespace . . .}>
  24. // Content: (annotation?)
  25. //</totalDigits>
  26. internal static XmlSchemaTotalDigitsFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
  27. {
  28. XmlSchemaTotalDigitsFacet td = new XmlSchemaTotalDigitsFacet();
  29. reader.MoveToElement();
  30. if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
  31. {
  32. error(h,"Should not happen :1: XmlSchemaTotalDigitsFacet.Read, name="+reader.Name,null);
  33. reader.Skip();
  34. return null;
  35. }
  36. td.LineNumber = reader.LineNumber;
  37. td.LinePosition = reader.LinePosition;
  38. td.SourceUri = reader.BaseURI;
  39. while(reader.MoveToNextAttribute())
  40. {
  41. if(reader.Name == "id")
  42. {
  43. td.Id = reader.Value;
  44. }
  45. else if(reader.Name == "fixed")
  46. {
  47. Exception innerex;
  48. td.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. td.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,td);
  63. }
  64. }
  65. reader.MoveToElement();
  66. if(reader.IsEmptyElement)
  67. return td;
  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: XmlSchemaTotalDigitsFacet.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. td.Annotation = annotation;
  84. continue;
  85. }
  86. reader.RaiseInvalidElementError();
  87. }
  88. return td;
  89. }
  90. }
  91. }