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 private DtdProcessing dtdProcessing
;
65 private long maxCharactersFromEntities
;
66 private long maxCharactersInDocument
;
69 public XmlReaderSettings ()
75 public event ValidationEventHandler ValidationEventHandler
;
78 public XmlReaderSettings
Clone ()
80 return (XmlReaderSettings
) MemberwiseClone ();
85 checkCharacters
= true;
86 closeInput
= false; // ? not documented
87 conformance
= ConformanceLevel
.Document
;
88 ignoreComments
= false;
89 ignoreProcessingInstructions
= false;
90 ignoreWhitespace
= false;
92 linePositionOffset
= 0;
95 xmlResolver
= new XmlXapResolver ();
98 schemasNeedsInitialization
= true;
100 XsValidationFlags
.ProcessIdentityConstraints
|
101 XsValidationFlags
.AllowXmlAttributes
;
102 validationType
= ValidationType
.None
;
103 xmlResolver
= new XmlUrlResolver ();
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; }
122 public DtdProcessing DtdProcessing
{
123 get { return dtdProcessing; }
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; }
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; }
181 public XmlSchemaSet Schemas
{
183 if (schemasNeedsInitialization
) {
184 schemas
= new XmlSchemaSet ();
185 schemasNeedsInitialization
= false;
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
)
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; }
219 public XmlResolver XmlResolver
{
220 internal get { return xmlResolver; }
221 set { xmlResolver = value; }