2 // System.Xml.Schema.XmlSchemaObject.cs
5 // Dwivedi, Ajay kumar Adwiv@Yahoo.com
6 // Enomoto, Atsushi ginga@kit.hi-ho.ne.jp
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:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
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.
30 using System
.Collections
;
31 using System
.Xml
.Serialization
;
34 namespace System
.Xml
.Schema
37 /// Summary description for XmlSchemaObject.
39 public abstract class XmlSchemaObject
41 private int lineNumber
;
42 private int linePosition
;
43 private string sourceUri
;
44 private XmlSerializerNamespaces namespaces
;
45 internal ArrayList unhandledAttributeList
;
46 internal bool isCompiled
= false;
47 internal int errorCount
= 0;
48 internal Guid CompilationId
;
49 internal Guid ValidationId
;
50 internal bool isRedefineChild
;
51 internal bool isRedefinedComponent
;
52 internal XmlSchemaObject redefinedObject
;
54 private XmlSchemaObject parent
;
57 protected XmlSchemaObject()
59 namespaces
= new XmlSerializerNamespaces();
60 unhandledAttributeList
= null;
61 CompilationId
= Guid
.Empty
;
67 get{ return lineNumber; }
68 set{ lineNumber = value; }
71 public int LinePosition
73 get{ return linePosition; }
74 set{ linePosition = value; }
77 public string SourceUri
79 get{ return sourceUri; }
80 set{ sourceUri = value; }
89 XmlSchemaObject Parent
{
90 get { return parent; }
91 set { parent = value; }
94 internal XmlSchema AncestorSchema
{
97 for (XmlSchemaObject o
= Parent
; o
!= null; o
= o
.Parent
)
100 throw new Exception (String
.Format ("INTERNAL ERROR: Parent object is not set properly : {0} ({1},{2})", SourceUri
, LineNumber
, LinePosition
));
104 internal virtual void SetParent (XmlSchemaObject parent
)
109 // Undocumented Property
110 [XmlNamespaceDeclarations
]
111 public XmlSerializerNamespaces Namespaces
113 get{ return namespaces; }
114 set{ namespaces = value; }
117 internal void error(ValidationEventHandler handle
,string message
)
120 error (handle
, message
, null, this, null);
122 internal void warn(ValidationEventHandler handle
,string message
)
124 warn (handle
, message
, null, this, null);
126 internal static void error(ValidationEventHandler handle
, string message
, Exception innerException
)
128 error (handle
, message
, innerException
, null, null);
130 internal static void warn(ValidationEventHandler handle
, string message
, Exception innerException
)
132 warn (handle
, message
, innerException
, null, null);
134 internal static void error(ValidationEventHandler handle
,
136 Exception innerException
,
137 XmlSchemaObject xsobj
,
140 ValidationHandler
.RaiseValidationEvent (handle
,
146 XmlSeverityType
.Error
);
148 internal static void warn(ValidationEventHandler handle
,
150 Exception innerException
,
151 XmlSchemaObject xsobj
,
154 ValidationHandler
.RaiseValidationEvent (handle
,
160 XmlSeverityType
.Warning
);
163 internal virtual int Compile (ValidationEventHandler h
, XmlSchema schema
)
168 internal virtual int Validate (ValidationEventHandler h
, XmlSchema schema
)
173 internal bool IsValidated (Guid validationId
)
175 return this.ValidationId
== validationId
;
178 // This method is used only by particles
179 internal virtual void CopyInfo (XmlSchemaParticle obj
)
181 obj
.LineNumber
= LineNumber
;
182 obj
.LinePosition
= LinePosition
;
183 obj
.SourceUri
= SourceUri
;
184 obj
.errorCount
= errorCount
;
185 // Other fields and properties may be useless for Particle.