2 // XmlReaderSettings.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // (C) 2004 Novell Inc.
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 using System.Xml.Schema;
39 using XsValidationFlags = System.Xml.Schema.XmlSchemaValidationFlags;
44 public sealed class XmlReaderSettings
46 private bool checkCharacters;
47 private bool closeInput;
48 private ConformanceLevel conformance;
49 private bool ignoreComments;
50 private bool ignoreProcessingInstructions;
51 private bool ignoreWhitespace;
52 private int lineNumberOffset;
53 private int linePositionOffset;
54 private bool prohibitDtd;
55 private XmlNameTable nameTable;
57 private XmlSchemaSet schemas;
58 private bool schemasNeedsInitialization;
59 private XsValidationFlags validationFlags;
60 private ValidationType validationType;
62 private XmlResolver xmlResolver;
64 public XmlReaderSettings ()
70 public event ValidationEventHandler ValidationEventHandler;
73 public XmlReaderSettings Clone ()
75 return (XmlReaderSettings) MemberwiseClone ();
80 checkCharacters = true;
81 closeInput = false; // ? not documented
82 conformance = ConformanceLevel.Document;
83 ignoreComments = false;
84 ignoreProcessingInstructions = false;
85 ignoreWhitespace = false;
87 linePositionOffset = 0;
91 schemasNeedsInitialization = true;
93 XsValidationFlags.ProcessIdentityConstraints |
94 XsValidationFlags.AllowXmlAttributes;
95 validationType = ValidationType.None;
97 xmlResolver = new XmlUrlResolver ();
100 public bool CheckCharacters {
101 get { return checkCharacters; }
102 set { checkCharacters = value; }
105 public bool CloseInput {
106 get { return closeInput; }
107 set { closeInput = value; }
110 public ConformanceLevel ConformanceLevel {
111 get { return conformance; }
112 set { conformance = value; }
115 public bool IgnoreComments {
116 get { return ignoreComments; }
117 set { ignoreComments = value; }
120 public bool IgnoreProcessingInstructions {
121 get { return ignoreProcessingInstructions; }
122 set { ignoreProcessingInstructions = value; }
125 public bool IgnoreWhitespace {
126 get { return ignoreWhitespace; }
127 set { ignoreWhitespace = value; }
130 public int LineNumberOffset {
131 get { return lineNumberOffset; }
132 set { lineNumberOffset = value; }
135 public int LinePositionOffset {
136 get { return linePositionOffset; }
137 set { linePositionOffset = value; }
140 public bool ProhibitDtd {
141 get { return prohibitDtd; }
142 set { prohibitDtd = value; }
145 // LAMESPEC: MSDN documentation says "An empty XmlNameTable
146 // object" for default value, but XmlNameTable cannot be
147 // instantiate. It actually returns null by default.
148 public XmlNameTable NameTable {
149 get { return nameTable; }
150 set { nameTable = value; }
154 public XmlSchemaSet Schemas {
156 if (schemasNeedsInitialization) {
157 schemas = new XmlSchemaSet ();
158 schemasNeedsInitialization = false;
164 schemasNeedsInitialization = false;
168 internal void OnValidationError (object o, ValidationEventArgs e)
170 if (ValidationEventHandler != null)
171 ValidationEventHandler (o, e);
172 else if (e.Severity == XmlSeverityType.Error)
176 internal void SetSchemas (XmlSchemaSet schemas)
178 this.schemas = schemas;
181 public XsValidationFlags ValidationFlags {
182 get { return validationFlags; }
183 set { validationFlags = value; }
186 public ValidationType ValidationType {
187 get { return validationType; }
188 set { validationType = value; }
192 public XmlResolver XmlResolver {
193 internal get { return xmlResolver; }
194 set { xmlResolver = value; }