XmlSchemaObject.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. //
  2. // System.Xml.Schema.XmlSchemaObject.cs
  3. //
  4. // Authors:
  5. // Dwivedi, Ajay kumar [email protected]
  6. // Enomoto, Atsushi [email protected]
  7. //
  8. using System;
  9. using System.Collections;
  10. using System.Xml.Serialization;
  11. using System.Xml;
  12. namespace System.Xml.Schema
  13. {
  14. /// <summary>
  15. /// Summary description for XmlSchemaObject.
  16. /// </summary>
  17. public abstract class XmlSchemaObject
  18. {
  19. private int lineNumber;
  20. private int linePosition;
  21. private string sourceUri;
  22. private XmlSerializerNamespaces namespaces;
  23. internal ArrayList unhandledAttributeList ;
  24. internal bool isCompiled = false;
  25. internal int errorCount = 0;
  26. internal Guid CompilationId;
  27. internal Guid ValidationId;
  28. internal bool isRedefineChild;
  29. internal bool isRedefinedComponent;
  30. internal XmlSchemaObject redefinedObject;
  31. protected XmlSchemaObject()
  32. {
  33. namespaces = new XmlSerializerNamespaces();
  34. unhandledAttributeList = null;
  35. CompilationId = Guid.Empty;
  36. }
  37. [XmlIgnore]
  38. public int LineNumber
  39. {
  40. get{ return lineNumber; }
  41. set{ lineNumber = value; }
  42. }
  43. [XmlIgnore]
  44. public int LinePosition
  45. {
  46. get{ return linePosition; }
  47. set{ linePosition = value; }
  48. }
  49. [XmlIgnore]
  50. public string SourceUri
  51. {
  52. get{ return sourceUri; }
  53. set{ sourceUri = value; }
  54. }
  55. // Undocumented Property
  56. [XmlNamespaceDeclarations]
  57. public XmlSerializerNamespaces Namespaces
  58. {
  59. get{ return namespaces; }
  60. set{ namespaces = value; }
  61. }
  62. internal void error(ValidationEventHandler handle,string message)
  63. {
  64. errorCount++;
  65. error (handle, message, null, this, null);
  66. }
  67. internal void warn(ValidationEventHandler handle,string message)
  68. {
  69. warn (handle, message, null, this, null);
  70. }
  71. internal static void error(ValidationEventHandler handle, string message, Exception innerException)
  72. {
  73. error (handle, message, innerException, null, null);
  74. }
  75. internal static void warn(ValidationEventHandler handle, string message, Exception innerException)
  76. {
  77. warn (handle, message, innerException, null, null);
  78. }
  79. internal static void error(ValidationEventHandler handle,
  80. string message,
  81. Exception innerException,
  82. XmlSchemaObject xsobj,
  83. object sender)
  84. {
  85. ValidationHandler.RaiseValidationEvent (handle,
  86. innerException,
  87. message,
  88. xsobj,
  89. sender,
  90. null,
  91. XmlSeverityType.Error);
  92. }
  93. internal static void warn(ValidationEventHandler handle,
  94. string message,
  95. Exception innerException,
  96. XmlSchemaObject xsobj,
  97. object sender)
  98. {
  99. ValidationHandler.RaiseValidationEvent (handle,
  100. innerException,
  101. message,
  102. xsobj,
  103. sender,
  104. null,
  105. XmlSeverityType.Warning);
  106. }
  107. internal virtual int Compile (ValidationEventHandler h, XmlSchema schema)
  108. {
  109. return 0;
  110. }
  111. internal bool IsComplied (Guid compilationId)
  112. {
  113. return this.CompilationId == compilationId;
  114. }
  115. internal virtual int Validate (ValidationEventHandler h, XmlSchema schema)
  116. {
  117. return 0;
  118. }
  119. internal bool IsValidated (Guid validationId)
  120. {
  121. return this.ValidationId == validationId;
  122. }
  123. // This method is used only by particles
  124. internal virtual void CopyInfo (XmlSchemaParticle obj)
  125. {
  126. obj.LineNumber = LineNumber;
  127. obj.LinePosition = LinePosition;
  128. obj.SourceUri = SourceUri;
  129. obj.errorCount = errorCount;
  130. // Other fields and properties may be useless for Particle.
  131. }
  132. }
  133. }