XmlSchemaObject.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. //
  2. // System.Xml.Schema.XmlSchemaObject.cs
  3. //
  4. // Authors:
  5. // Dwivedi, Ajay kumar [email protected]
  6. // Enomoto, Atsushi [email protected]
  7. //
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System;
  29. using System.Collections;
  30. using System.Xml.Serialization;
  31. using System.Xml;
  32. namespace System.Xml.Schema
  33. {
  34. /// <summary>
  35. /// Summary description for XmlSchemaObject.
  36. /// </summary>
  37. public abstract class XmlSchemaObject
  38. {
  39. private int lineNumber;
  40. private int linePosition;
  41. private string sourceUri;
  42. private XmlSerializerNamespaces namespaces;
  43. internal ArrayList unhandledAttributeList ;
  44. internal bool isCompiled = false;
  45. internal int errorCount = 0;
  46. internal Guid CompilationId;
  47. internal Guid ValidationId;
  48. internal bool isRedefineChild;
  49. internal bool isRedefinedComponent;
  50. internal XmlSchemaObject redefinedObject;
  51. #if NET_2_0
  52. private XmlSchemaObject parent;
  53. #endif
  54. protected XmlSchemaObject()
  55. {
  56. namespaces = new XmlSerializerNamespaces();
  57. unhandledAttributeList = null;
  58. CompilationId = Guid.Empty;
  59. }
  60. [XmlIgnore]
  61. public int LineNumber
  62. {
  63. get{ return lineNumber; }
  64. set{ lineNumber = value; }
  65. }
  66. [XmlIgnore]
  67. public int LinePosition
  68. {
  69. get{ return linePosition; }
  70. set{ linePosition = value; }
  71. }
  72. [XmlIgnore]
  73. public string SourceUri
  74. {
  75. get{ return sourceUri; }
  76. set{ sourceUri = value; }
  77. }
  78. #if NET_2_0
  79. [XmlIgnore]
  80. public XmlSchemaObject Parent {
  81. get { return parent; }
  82. set { parent = value; }
  83. }
  84. #endif
  85. // Undocumented Property
  86. [XmlNamespaceDeclarations]
  87. public XmlSerializerNamespaces Namespaces
  88. {
  89. get{ return namespaces; }
  90. set{ namespaces = value; }
  91. }
  92. internal void error(ValidationEventHandler handle,string message)
  93. {
  94. errorCount++;
  95. error (handle, message, null, this, null);
  96. }
  97. internal void warn(ValidationEventHandler handle,string message)
  98. {
  99. warn (handle, message, null, this, null);
  100. }
  101. internal static void error(ValidationEventHandler handle, string message, Exception innerException)
  102. {
  103. error (handle, message, innerException, null, null);
  104. }
  105. internal static void warn(ValidationEventHandler handle, string message, Exception innerException)
  106. {
  107. warn (handle, message, innerException, null, null);
  108. }
  109. internal static void error(ValidationEventHandler handle,
  110. string message,
  111. Exception innerException,
  112. XmlSchemaObject xsobj,
  113. object sender)
  114. {
  115. ValidationHandler.RaiseValidationEvent (handle,
  116. innerException,
  117. message,
  118. xsobj,
  119. sender,
  120. null,
  121. XmlSeverityType.Error);
  122. }
  123. internal static void warn(ValidationEventHandler handle,
  124. string message,
  125. Exception innerException,
  126. XmlSchemaObject xsobj,
  127. object sender)
  128. {
  129. ValidationHandler.RaiseValidationEvent (handle,
  130. innerException,
  131. message,
  132. xsobj,
  133. sender,
  134. null,
  135. XmlSeverityType.Warning);
  136. }
  137. internal virtual int Compile (ValidationEventHandler h, XmlSchema schema)
  138. {
  139. return 0;
  140. }
  141. internal bool IsComplied (Guid compilationId)
  142. {
  143. return this.CompilationId == compilationId;
  144. }
  145. internal virtual int Validate (ValidationEventHandler h, XmlSchema schema)
  146. {
  147. return 0;
  148. }
  149. internal bool IsValidated (Guid validationId)
  150. {
  151. return this.ValidationId == validationId;
  152. }
  153. // This method is used only by particles
  154. internal virtual void CopyInfo (XmlSchemaParticle obj)
  155. {
  156. obj.LineNumber = LineNumber;
  157. obj.LinePosition = LinePosition;
  158. obj.SourceUri = SourceUri;
  159. obj.errorCount = errorCount;
  160. // Other fields and properties may be useless for Particle.
  161. }
  162. }
  163. }