2010-04-06 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.XML / System.Xml.Schema / XmlSchemaObject.cs
blob6f1f3f7ebfade6e542d1cf026a779c1745d398a9
1 //
2 // System.Xml.Schema.XmlSchemaObject.cs
3 //
4 // Authors:
5 // Dwivedi, Ajay kumar Adwiv@Yahoo.com
6 // Enomoto, Atsushi ginga@kit.hi-ho.ne.jp
7 //
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.
29 using System;
30 using System.Collections;
31 using System.Xml.Serialization;
32 using System.Xml;
34 namespace System.Xml.Schema
36 /// <summary>
37 /// Summary description for XmlSchemaObject.
38 /// </summary>
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;
64 [XmlIgnore]
65 public int LineNumber
67 get{ return lineNumber; }
68 set{ lineNumber = value; }
70 [XmlIgnore]
71 public int LinePosition
73 get{ return linePosition; }
74 set{ linePosition = value; }
76 [XmlIgnore]
77 public string SourceUri
79 get{ return sourceUri; }
80 set{ sourceUri = value; }
83 #if NET_2_0
84 [XmlIgnore]
85 public
86 #else
87 internal
88 #endif
89 XmlSchemaObject Parent {
90 get { return parent; }
91 set { parent = value; }
94 internal XmlSchema AncestorSchema {
95 get {
97 for (XmlSchemaObject o = Parent; o != null; o = o.Parent)
98 if (o is XmlSchema)
99 return (XmlSchema) o;
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)
106 Parent = 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)
119 errorCount++;
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,
135 string message,
136 Exception innerException,
137 XmlSchemaObject xsobj,
138 object sender)
140 ValidationHandler.RaiseValidationEvent (handle,
141 innerException,
142 message,
143 xsobj,
144 sender,
145 null,
146 XmlSeverityType.Error);
148 internal static void warn(ValidationEventHandler handle,
149 string message,
150 Exception innerException,
151 XmlSchemaObject xsobj,
152 object sender)
154 ValidationHandler.RaiseValidationEvent (handle,
155 innerException,
156 message,
157 xsobj,
158 sender,
159 null,
160 XmlSeverityType.Warning);
163 internal virtual int Compile (ValidationEventHandler h, XmlSchema schema)
165 return 0;
168 internal virtual int Validate (ValidationEventHandler h, XmlSchema schema)
170 return 0;
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.