XmlSchemaObject.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. protected XmlSchemaObject()
  52. {
  53. namespaces = new XmlSerializerNamespaces();
  54. unhandledAttributeList = null;
  55. CompilationId = Guid.Empty;
  56. }
  57. [XmlIgnore]
  58. public int LineNumber
  59. {
  60. get{ return lineNumber; }
  61. set{ lineNumber = value; }
  62. }
  63. [XmlIgnore]
  64. public int LinePosition
  65. {
  66. get{ return linePosition; }
  67. set{ linePosition = value; }
  68. }
  69. [XmlIgnore]
  70. public string SourceUri
  71. {
  72. get{ return sourceUri; }
  73. set{ sourceUri = value; }
  74. }
  75. // Undocumented Property
  76. [XmlNamespaceDeclarations]
  77. public XmlSerializerNamespaces Namespaces
  78. {
  79. get{ return namespaces; }
  80. set{ namespaces = value; }
  81. }
  82. internal void error(ValidationEventHandler handle,string message)
  83. {
  84. errorCount++;
  85. error (handle, message, null, this, null);
  86. }
  87. internal void warn(ValidationEventHandler handle,string message)
  88. {
  89. warn (handle, message, null, this, null);
  90. }
  91. internal static void error(ValidationEventHandler handle, string message, Exception innerException)
  92. {
  93. error (handle, message, innerException, null, null);
  94. }
  95. internal static void warn(ValidationEventHandler handle, string message, Exception innerException)
  96. {
  97. warn (handle, message, innerException, null, null);
  98. }
  99. internal static void error(ValidationEventHandler handle,
  100. string message,
  101. Exception innerException,
  102. XmlSchemaObject xsobj,
  103. object sender)
  104. {
  105. ValidationHandler.RaiseValidationEvent (handle,
  106. innerException,
  107. message,
  108. xsobj,
  109. sender,
  110. null,
  111. XmlSeverityType.Error);
  112. }
  113. internal static void warn(ValidationEventHandler handle,
  114. string message,
  115. Exception innerException,
  116. XmlSchemaObject xsobj,
  117. object sender)
  118. {
  119. ValidationHandler.RaiseValidationEvent (handle,
  120. innerException,
  121. message,
  122. xsobj,
  123. sender,
  124. null,
  125. XmlSeverityType.Warning);
  126. }
  127. internal virtual int Compile (ValidationEventHandler h, XmlSchema schema)
  128. {
  129. return 0;
  130. }
  131. internal bool IsComplied (Guid compilationId)
  132. {
  133. return this.CompilationId == compilationId;
  134. }
  135. internal virtual int Validate (ValidationEventHandler h, XmlSchema schema)
  136. {
  137. return 0;
  138. }
  139. internal bool IsValidated (Guid validationId)
  140. {
  141. return this.ValidationId == validationId;
  142. }
  143. // This method is used only by particles
  144. internal virtual void CopyInfo (XmlSchemaParticle obj)
  145. {
  146. obj.LineNumber = LineNumber;
  147. obj.LinePosition = LinePosition;
  148. obj.SourceUri = SourceUri;
  149. obj.errorCount = errorCount;
  150. // Other fields and properties may be useless for Particle.
  151. }
  152. }
  153. }