XmlReaderSettings.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. using XsValidationFlags = System.Xml.Schema.XmlSchemaValidationFlags;
  35. namespace System.Xml
  36. {
  37. public class XmlReaderSettings
  38. {
  39. private bool checkCharacters;
  40. private bool closeInput;
  41. private ConformanceLevel conformance;
  42. private bool ignoreComments;
  43. private bool ignoreProcessingInstructions;
  44. private bool ignoreWhitespace;
  45. private int lineNumberOffset;
  46. private int linePositionOffset;
  47. private bool prohibitDtd;
  48. private XmlNameTable nameTable;
  49. private XmlSchemaSet schemas;
  50. private XsValidationFlags validationFlags;
  51. private ValidationType validationType;
  52. public XmlReaderSettings ()
  53. {
  54. Reset ();
  55. }
  56. private XmlReaderSettings (XmlReaderSettings org)
  57. {
  58. checkCharacters = org.checkCharacters;
  59. closeInput = org.closeInput;
  60. conformance = org.conformance;
  61. ignoreComments = org.ignoreComments;
  62. ignoreProcessingInstructions =
  63. org.ignoreProcessingInstructions;
  64. ignoreWhitespace = org.ignoreWhitespace;
  65. lineNumberOffset = org.lineNumberOffset;
  66. linePositionOffset = org.linePositionOffset;
  67. prohibitDtd = org.prohibitDtd;
  68. schemas = org.schemas;
  69. validationFlags = org.validationFlags;
  70. validationType = org.validationType;
  71. nameTable = org.NameTable;
  72. }
  73. public event ValidationEventHandler ValidationEventHandler;
  74. public XmlReaderSettings Clone ()
  75. {
  76. return new XmlReaderSettings (this);
  77. }
  78. public void Reset ()
  79. {
  80. checkCharacters = true;
  81. closeInput = false; // ? not documented
  82. conformance = ConformanceLevel.Document;
  83. ignoreComments = false;
  84. ignoreProcessingInstructions = false;
  85. ignoreWhitespace = false;
  86. lineNumberOffset = 0;
  87. linePositionOffset = 0;
  88. prohibitDtd = false; // ? not documented
  89. schemas = new XmlSchemaSet ();
  90. validationFlags =
  91. XsValidationFlags.IgnoreValidationWarnings
  92. | XsValidationFlags.IgnoreSchemaLocation
  93. | XsValidationFlags.IgnoreInlineSchema;
  94. validationType = ValidationType.None;
  95. }
  96. public bool CheckCharacters {
  97. get { return checkCharacters; }
  98. set { checkCharacters = value; }
  99. }
  100. public bool CloseInput {
  101. get { return closeInput; }
  102. set { closeInput = value; }
  103. }
  104. public ConformanceLevel ConformanceLevel {
  105. get { return conformance; }
  106. set { conformance = value; }
  107. }
  108. public bool IgnoreComments {
  109. get { return ignoreComments; }
  110. set { ignoreComments = value; }
  111. }
  112. public bool IgnoreProcessingInstructions {
  113. get { return ignoreProcessingInstructions; }
  114. set { ignoreProcessingInstructions = value; }
  115. }
  116. public bool IgnoreWhitespace {
  117. get { return ignoreWhitespace; }
  118. set { ignoreWhitespace = value; }
  119. }
  120. public int LineNumberOffset {
  121. get { return lineNumberOffset; }
  122. set { lineNumberOffset = value; }
  123. }
  124. public int LinePositionOffset {
  125. get { return linePositionOffset; }
  126. set { linePositionOffset = value; }
  127. }
  128. public bool ProhibitDtd {
  129. get { return prohibitDtd; }
  130. set { prohibitDtd = value; }
  131. }
  132. // LAMESPEC: MSDN documentation says "An empty XmlNameTable
  133. // object" for default value, but XmlNameTable cannot be
  134. // instantiate. It actually returns null by default.
  135. public XmlNameTable NameTable {
  136. get { return nameTable; }
  137. set { nameTable = value; }
  138. }
  139. // LAMESPEC: Apparently, this property should not have a setter.
  140. public XmlSchemaSet Schemas {
  141. get { return schemas; }
  142. set {
  143. throw new XmlException ("XmlReaderSettings.Schemas is read-only and cannot be set.");
  144. }
  145. }
  146. public XsValidationFlags ValidationFlags {
  147. get { return validationFlags; }
  148. set { validationFlags = value; }
  149. }
  150. public ValidationType ValidationType {
  151. get { return validationType; }
  152. set { validationType = value; }
  153. }
  154. }
  155. }
  156. #endif