XmlSchemaValidator.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. //
  2. // XmlSchemaValidator.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // (C)2004 Novell Inc,
  8. //
  9. #if NET_2_0
  10. using System;
  11. using System.Collections;
  12. using System.IO;
  13. using System.Text;
  14. using System.Xml;
  15. using QName = System.Xml.XmlQualifiedName;
  16. using Form = System.Xml.Schema.XmlSchemaForm;
  17. using Use = System.Xml.Schema.XmlSchemaUse;
  18. using ContentType = System.Xml.Schema.XmlSchemaContentType;
  19. using Validity = System.Xml.Schema.XmlSchemaValidity;
  20. using ValidationFlags = System.Xml.Schema.XmlSchemaValidationFlags;
  21. using SOMList = System.Xml.Schema.XmlSchemaObjectCollection;
  22. using SOMObject = System.Xml.Schema.XmlSchemaObject;
  23. using Element = System.Xml.Schema.XmlSchemaElement;
  24. using Attr = System.Xml.Schema.XmlSchemaAttribute;
  25. using AttrGroup = System.Xml.Schema.XmlSchemaAttributeGroup;
  26. using AttrGroupRef = System.Xml.Schema.XmlSchemaAttributeGroupRef;
  27. using SimpleType = System.Xml.Schema.XmlSchemaSimpleType;
  28. using ComplexType = System.Xml.Schema.XmlSchemaComplexType;
  29. using SimpleModel = System.Xml.Schema.XmlSchemaSimpleContent;
  30. using SimpleExt = System.Xml.Schema.XmlSchemaSimpleContentExtension;
  31. using SimpleRst = System.Xml.Schema.XmlSchemaSimpleContentRestriction;
  32. using ComplexModel = System.Xml.Schema.XmlSchemaComplexContent;
  33. using ComplexExt = System.Xml.Schema.XmlSchemaComplexContentExtension;
  34. using ComplexRst = System.Xml.Schema.XmlSchemaComplexContentRestriction;
  35. using SimpleTypeRst = System.Xml.Schema.XmlSchemaSimpleTypeRestriction;
  36. using SimpleList = System.Xml.Schema.XmlSchemaSimpleTypeList;
  37. using SimpleUnion = System.Xml.Schema.XmlSchemaSimpleTypeUnion;
  38. using SchemaFacet = System.Xml.Schema.XmlSchemaFacet;
  39. using LengthFacet = System.Xml.Schema.XmlSchemaLengthFacet;
  40. using MinLengthFacet = System.Xml.Schema.XmlSchemaMinLengthFacet;
  41. using Particle = System.Xml.Schema.XmlSchemaParticle;
  42. using Sequence = System.Xml.Schema.XmlSchemaSequence;
  43. using Choice = System.Xml.Schema.XmlSchemaChoice;
  44. namespace System.Xml.Schema
  45. {
  46. public class XmlSchemaValidator
  47. {
  48. public XmlSchemaValidator (
  49. XmlNameTable nameTable,
  50. XmlSchemaSet schemas,
  51. IXmlNamespaceResolver nsResolver,
  52. ValidationFlags options)
  53. {
  54. this.nameTable = nameTable;
  55. this.schemas = schemas;
  56. this.nsResolver = nsResolver;
  57. this.options = options;
  58. }
  59. #region Fields
  60. // XmlReader/XPathNavigator themselves
  61. object nominalEventSender;
  62. IXmlLineInfo lineInfo;
  63. IXmlNamespaceResolver nsResolver;
  64. // These fields will be from XmlReaderSettings or
  65. // XPathNavigator.CheckValidity(). BTW, I think we could
  66. // implement XPathNavigator.CheckValidity() with
  67. // XsdValidatingReader.
  68. XmlNameTable nameTable;
  69. XmlSchemaSet schemas;
  70. XmlResolver xmlResolver;
  71. // "partialValidationType". but not sure how it will be used.
  72. SOMObject startType;
  73. // Below are maybe from XmlReaderSettings, but XPathNavigator
  74. // does not have it.
  75. ValidationFlags options;
  76. SOMObject currentType;
  77. #endregion
  78. #region Properties
  79. // Settable Properties
  80. // IMHO It should just be an event that fires another event.
  81. public event ValidationEventHandler ValidationEventHandler;
  82. public object ValidationEventSender {
  83. get { return nominalEventSender; }
  84. set { nominalEventSender = value; }
  85. }
  86. // (kinda) Construction Properties
  87. public IXmlLineInfo LineInfoProvider {
  88. get { return lineInfo; }
  89. set { lineInfo = value; }
  90. }
  91. public XmlResolver XmlResolver {
  92. set { xmlResolver = value; }
  93. }
  94. [MonoTODO]
  95. public string SourceUri {
  96. get { throw new NotImplementedException (); }
  97. }
  98. #endregion
  99. #region Methods
  100. // State Monitor
  101. [MonoTODO]
  102. public XmlSchemaAttribute [] GetExpectedAttributes ()
  103. {
  104. throw new NotImplementedException ();
  105. }
  106. [MonoTODO]
  107. public XmlSchemaParticle [] GetExpectedParticles ()
  108. {
  109. throw new NotImplementedException ();
  110. }
  111. [MonoTODO]
  112. public void GetUnspecifiedDefaultAttributes (ArrayList list)
  113. {
  114. throw new NotImplementedException ();
  115. }
  116. [MonoTODO]
  117. public object FindID (string name)
  118. {
  119. throw new NotImplementedException ();
  120. }
  121. // State Controller
  122. public void Init ()
  123. {
  124. Init (null);
  125. }
  126. public void Init (SOMObject startType)
  127. {
  128. this.startType = startType;
  129. }
  130. // It must be called at the end of the validation (to check
  131. // identity constraints etc.).
  132. [MonoTODO]
  133. public void EndValidation ()
  134. {
  135. throw new NotImplementedException ();
  136. }
  137. [MonoTODO]
  138. public void SkipToEndElement (XmlSchemaInfo info)
  139. {
  140. throw new NotImplementedException ();
  141. }
  142. // I guess this weird XmlValueGetter is for such case that
  143. // value might not be required (and thus it improves
  144. // performance in some cases. Doh.
  145. // AttDeriv
  146. [MonoTODO]
  147. public object ValidateAttribute (
  148. string localName,
  149. string ns,
  150. XmlValueGetter attributeValue,
  151. XmlSchemaInfo info)
  152. {
  153. throw new NotImplementedException ();
  154. }
  155. // StartTagOpenDeriv
  156. [MonoTODO]
  157. public void ValidateElement (
  158. string localName,
  159. string ns,
  160. XmlSchemaInfo info) // How is it used?
  161. {
  162. throw new NotImplementedException ();
  163. }
  164. [MonoTODO]
  165. public object ValidateEndElement (XmlSchemaInfo scheaInfo)
  166. {
  167. throw new NotImplementedException ();
  168. }
  169. [MonoTODO]
  170. public object ValidateEndElement (XmlSchemaInfo scheaInfo,
  171. object var)
  172. {
  173. throw new NotImplementedException ();
  174. }
  175. // StartTagCloseDeriv
  176. [MonoTODO]
  177. public void ValidateEndOfAttributes ()
  178. {
  179. throw new NotImplementedException ();
  180. }
  181. // TextDeriv ... without text. Maybe typed check is done by
  182. // ValidateAtomicValue().
  183. [MonoTODO]
  184. public void ValidateText (XmlValueGetter getter)
  185. {
  186. throw new NotImplementedException ();
  187. }
  188. [MonoTODO]
  189. public void ValidateWhitespace (XmlValueGetter getter)
  190. {
  191. throw new NotImplementedException ();
  192. }
  193. #endregion
  194. }
  195. }
  196. #endif