XmlReaderSettings.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. //
  2. // XmlReaderSettings.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // (C) 2004 Novell Inc.
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System;
  31. using System.IO;
  32. using System.Net;
  33. using System.Xml.Schema;
  34. namespace System.Xml
  35. {
  36. public class XmlReaderSettings
  37. {
  38. private bool checkCharacters;
  39. private bool closeInput;
  40. private ConformanceLevel conformance;
  41. private bool dtdValidate;
  42. private bool ignoreComments;
  43. private bool ignoreIdentityConstraints;
  44. private bool ignoreInlineSchema;
  45. private bool ignoreProcessingInstructions;
  46. private bool ignoreSchemaLocation;
  47. private bool ignoreValidationWarnings;
  48. private bool ignoreWhitespace;
  49. private int lineNumberOffset;
  50. private int linePositionOffset;
  51. private bool prohibitDtd;
  52. private XmlNameTable nameTable;
  53. private XmlSchemaSet schemas;
  54. private bool xsdValidate;
  55. public XmlReaderSettings ()
  56. {
  57. Reset ();
  58. }
  59. private XmlReaderSettings (XmlReaderSettings org)
  60. {
  61. checkCharacters = org.checkCharacters;
  62. closeInput = org.closeInput;
  63. conformance = org.conformance;
  64. dtdValidate = org.dtdValidate;
  65. ignoreComments = org.ignoreComments;
  66. ignoreIdentityConstraints =
  67. org.ignoreIdentityConstraints;
  68. ignoreInlineSchema = org.ignoreInlineSchema;
  69. ignoreProcessingInstructions =
  70. org.ignoreProcessingInstructions;
  71. ignoreSchemaLocation = org.ignoreSchemaLocation;
  72. ignoreValidationWarnings = org.ignoreValidationWarnings;
  73. ignoreWhitespace = org.ignoreWhitespace;
  74. lineNumberOffset = org.lineNumberOffset;
  75. linePositionOffset = org.linePositionOffset;
  76. prohibitDtd = org.prohibitDtd;
  77. schemas = org.schemas;
  78. xsdValidate = org.xsdValidate;
  79. nameTable = org.NameTable;
  80. }
  81. public event ValidationEventHandler ValidationEventHandler;
  82. public XmlReaderSettings Clone ()
  83. {
  84. return new XmlReaderSettings (this);
  85. }
  86. public void Reset ()
  87. {
  88. checkCharacters = true;
  89. closeInput = false; // ? not documented
  90. conformance = ConformanceLevel.Document;
  91. dtdValidate = false;
  92. ignoreComments = false;
  93. ignoreIdentityConstraints = false; // ? not documented
  94. ignoreInlineSchema = true;
  95. ignoreProcessingInstructions = false;
  96. ignoreSchemaLocation = true;
  97. ignoreValidationWarnings = true;
  98. ignoreWhitespace = false;
  99. lineNumberOffset = 0;
  100. linePositionOffset = 0;
  101. prohibitDtd = false; // ? not documented
  102. schemas = new XmlSchemaSet ();
  103. xsdValidate = false;
  104. }
  105. public bool CheckCharacters {
  106. get { return checkCharacters; }
  107. set { checkCharacters = value; }
  108. }
  109. public bool CloseInput {
  110. get { return closeInput; }
  111. set { closeInput = value; }
  112. }
  113. public ConformanceLevel ConformanceLevel {
  114. get { return conformance; }
  115. set { conformance = value; }
  116. }
  117. public bool DtdValidate {
  118. get { return dtdValidate; }
  119. set { dtdValidate = value; }
  120. }
  121. public bool IgnoreComments {
  122. get { return ignoreComments; }
  123. set { ignoreComments = value; }
  124. }
  125. public bool IgnoreIdentityConstraints {
  126. get { return ignoreIdentityConstraints ; }
  127. set { ignoreIdentityConstraints = value; }
  128. }
  129. public bool IgnoreInlineSchema {
  130. get { return ignoreInlineSchema; }
  131. set { ignoreInlineSchema = value; }
  132. }
  133. public bool IgnoreProcessingInstructions {
  134. get { return ignoreProcessingInstructions; }
  135. set { ignoreProcessingInstructions = value; }
  136. }
  137. public bool IgnoreSchemaLocation {
  138. get { return ignoreSchemaLocation; }
  139. set { ignoreSchemaLocation = value; }
  140. }
  141. public bool IgnoreValidationWarnings {
  142. get { return ignoreValidationWarnings; }
  143. set { ignoreValidationWarnings = value; }
  144. }
  145. public bool IgnoreWhitespace {
  146. get { return ignoreWhitespace; }
  147. set { ignoreWhitespace = value; }
  148. }
  149. public int LineNumberOffset {
  150. get { return lineNumberOffset; }
  151. set { lineNumberOffset = value; }
  152. }
  153. public int LinePositionOffset {
  154. get { return linePositionOffset; }
  155. set { linePositionOffset = value; }
  156. }
  157. public bool ProhibitDtd {
  158. get { return prohibitDtd; }
  159. set { prohibitDtd = value; }
  160. }
  161. // LAMESPEC: MSDN documentation says "An empty XmlNameTable
  162. // object" for default value, but XmlNameTable cannot be
  163. // instantiate. It actually returns null by default.
  164. public XmlNameTable NameTable {
  165. get { return nameTable; }
  166. set { nameTable = value; }
  167. }
  168. // LAMESPEC: Apparently, this property should not have a setter.
  169. public XmlSchemaSet Schemas {
  170. get { return schemas; }
  171. set {
  172. throw new XmlException ("XmlReaderSettings.Schemas is read-only and cannot be set.");
  173. }
  174. }
  175. public bool XsdValidate {
  176. get { return xsdValidate; }
  177. set { xsdValidate = value; }
  178. }
  179. }
  180. }
  181. #endif