2010-04-07 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.XML / System.Xml / XmlReaderSettings.cs
blob444ec804691546844618bd3b0ded907058f5bb1f
1 //
2 // XmlReaderSettings.cs
3 //
4 // Author:
5 // Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // (C) 2004 Novell Inc.
8 //
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:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
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.
31 #if NET_2_0
33 using System;
34 using System.IO;
35 using System.Net;
36 using System.Xml.Schema;
38 #if !MOONLIGHT
39 using XsValidationFlags = System.Xml.Schema.XmlSchemaValidationFlags;
40 #endif
42 namespace System.Xml
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;
56 #if !MOONLIGHT
57 private XmlSchemaSet schemas;
58 private bool schemasNeedsInitialization;
59 private XsValidationFlags validationFlags;
60 private ValidationType validationType;
61 #endif
62 private XmlResolver xmlResolver;
63 #if MOONLIGHT
64 private DtdProcessing dtdProcessing;
65 private long maxCharactersFromEntities;
66 private long maxCharactersInDocument;
67 #endif
69 public XmlReaderSettings ()
71 Reset ();
74 #if !MOONLIGHT
75 public event ValidationEventHandler ValidationEventHandler;
76 #endif
78 public XmlReaderSettings Clone ()
80 return (XmlReaderSettings) MemberwiseClone ();
83 public void Reset ()
85 checkCharacters = true;
86 closeInput = false; // ? not documented
87 conformance = ConformanceLevel.Document;
88 ignoreComments = false;
89 ignoreProcessingInstructions = false;
90 ignoreWhitespace = false;
91 lineNumberOffset = 0;
92 linePositionOffset = 0;
93 prohibitDtd = true;
94 #if MOONLIGHT
95 xmlResolver = new XmlXapResolver ();
96 #else
97 schemas = null;
98 schemasNeedsInitialization = true;
99 validationFlags =
100 XsValidationFlags.ProcessIdentityConstraints |
101 XsValidationFlags.AllowXmlAttributes;
102 validationType = ValidationType.None;
103 xmlResolver = new XmlUrlResolver ();
104 #endif
107 public bool CheckCharacters {
108 get { return checkCharacters; }
109 set { checkCharacters = value; }
112 public bool CloseInput {
113 get { return closeInput; }
114 set { closeInput = value; }
117 public ConformanceLevel ConformanceLevel {
118 get { return conformance; }
119 set { conformance = value; }
121 #if MOONLIGHT
122 public DtdProcessing DtdProcessing {
123 get { return dtdProcessing; }
124 set {
125 dtdProcessing = value;
126 prohibitDtd = (value == DtdProcessing.Prohibit);
130 public long MaxCharactersFromEntities {
131 get { return maxCharactersFromEntities; }
132 set { maxCharactersFromEntities = value; }
135 [MonoTODO ("not used yet")]
136 public long MaxCharactersInDocument {
137 get { return maxCharactersInDocument; }
138 set { maxCharactersInDocument = value; }
140 #endif
142 public bool IgnoreComments {
143 get { return ignoreComments; }
144 set { ignoreComments = value; }
147 public bool IgnoreProcessingInstructions {
148 get { return ignoreProcessingInstructions; }
149 set { ignoreProcessingInstructions = value; }
152 public bool IgnoreWhitespace {
153 get { return ignoreWhitespace; }
154 set { ignoreWhitespace = value; }
157 public int LineNumberOffset {
158 get { return lineNumberOffset; }
159 set { lineNumberOffset = value; }
162 public int LinePositionOffset {
163 get { return linePositionOffset; }
164 set { linePositionOffset = value; }
167 public bool ProhibitDtd {
168 get { return prohibitDtd; }
169 set { prohibitDtd = value; }
172 // LAMESPEC: MSDN documentation says "An empty XmlNameTable
173 // object" for default value, but XmlNameTable cannot be
174 // instantiate. It actually returns null by default.
175 public XmlNameTable NameTable {
176 get { return nameTable; }
177 set { nameTable = value; }
180 #if !MOONLIGHT
181 public XmlSchemaSet Schemas {
182 get {
183 if (schemasNeedsInitialization) {
184 schemas = new XmlSchemaSet ();
185 schemasNeedsInitialization = false;
187 return schemas;
189 set {
190 schemas = value;
191 schemasNeedsInitialization = false;
195 internal void OnValidationError (object o, ValidationEventArgs e)
197 if (ValidationEventHandler != null)
198 ValidationEventHandler (o, e);
199 else if (e.Severity == XmlSeverityType.Error)
200 throw e.Exception;
203 internal void SetSchemas (XmlSchemaSet schemas)
205 this.schemas = schemas;
208 public XsValidationFlags ValidationFlags {
209 get { return validationFlags; }
210 set { validationFlags = value; }
213 public ValidationType ValidationType {
214 get { return validationType; }
215 set { validationType = value; }
217 #endif
219 public XmlResolver XmlResolver {
220 internal get { return xmlResolver; }
221 set { xmlResolver = value; }
226 #endif