**** Merged r36954 from MCS ****
[mono.git] / mcs / class / System.XML / System.Xml.Schema / XmlSchemaObject.cs
1 //\r
2 // System.Xml.Schema.XmlSchemaObject.cs\r
3 //\r
4 // Authors:\r
5 //      Dwivedi, Ajay kumar  Adwiv@Yahoo.com\r
6 //      Enomoto, Atsushi     ginga@kit.hi-ho.ne.jp\r
7 //\r
8
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.
28 //
29 using System;\r
30 using System.Collections;\r
31 using System.Xml.Serialization;\r
32 using System.Xml;\r
33 \r
34 namespace System.Xml.Schema\r
35 {\r
36         /// <summary>\r
37         /// Summary description for XmlSchemaObject.\r
38         /// </summary>\r
39         public abstract class XmlSchemaObject\r
40         {\r
41                 private int lineNumber;\r
42                 private int linePosition;\r
43                 private string sourceUri;\r
44                 private XmlSerializerNamespaces namespaces;\r
45                 internal ArrayList unhandledAttributeList ;\r
46                 internal bool isCompiled = false;\r
47                 internal int errorCount = 0;\r
48                 internal Guid CompilationId;\r
49                 internal Guid ValidationId;\r
50                 internal bool isRedefineChild;\r
51                 internal bool isRedefinedComponent;\r
52                 internal XmlSchemaObject redefinedObject;\r
53 \r
54 #if NET_2_0\r
55                 private XmlSchemaObject parent;\r
56 #endif\r
57 \r
58 \r
59                 protected XmlSchemaObject()\r
60                 {\r
61                         namespaces = new XmlSerializerNamespaces();\r
62                         unhandledAttributeList = null;\r
63                         CompilationId = Guid.Empty;\r
64                 }\r
65 \r
66                 [XmlIgnore]\r
67                 public int LineNumber \r
68                 { \r
69                         get{ return lineNumber; } \r
70                         set{ lineNumber = value; } \r
71                 }\r
72                 [XmlIgnore]\r
73                 public int LinePosition \r
74                 { \r
75                         get{ return linePosition; } \r
76                         set{ linePosition = value; } \r
77                 }\r
78                 [XmlIgnore]\r
79                 public string SourceUri \r
80                 { \r
81                         get{ return sourceUri; } \r
82                         set{ sourceUri = value; } \r
83                 }\r
84 \r
85 #if NET_2_0\r
86                 [XmlIgnore]\r
87                 public XmlSchemaObject Parent {\r
88                         get { return parent; }\r
89                         set { parent = value; }\r
90                 }\r
91 #endif\r
92 \r
93                 // Undocumented Property\r
94                 [XmlNamespaceDeclarations]\r
95                 public XmlSerializerNamespaces Namespaces \r
96                 { \r
97                         get{ return namespaces; } \r
98                         set{ namespaces = value; } \r
99                 }\r
100 \r
101                 internal void error(ValidationEventHandler handle,string message)\r
102                 {\r
103                         errorCount++;\r
104                         error (handle, message, null, this, null);\r
105                 }\r
106                 internal void warn(ValidationEventHandler handle,string message)\r
107                 {\r
108                         warn (handle, message, null, this, null);\r
109                 }\r
110                 internal static void error(ValidationEventHandler handle, string message, Exception innerException)\r
111                 {\r
112                         error (handle, message, innerException, null, null);\r
113                 }\r
114                 internal static void warn(ValidationEventHandler handle, string message, Exception innerException)\r
115                 {\r
116                         warn (handle, message, innerException, null, null);\r
117                 }\r
118                 internal static void error(ValidationEventHandler handle,\r
119                         string message,\r
120                         Exception innerException,\r
121                         XmlSchemaObject xsobj,\r
122                         object sender)\r
123                 {\r
124                         ValidationHandler.RaiseValidationEvent (handle,\r
125                                 innerException,\r
126                                 message,\r
127                                 xsobj,\r
128                                 sender,\r
129                                 null,\r
130                                 XmlSeverityType.Error);\r
131                 }\r
132                 internal static void warn(ValidationEventHandler handle,\r
133                         string message,\r
134                         Exception innerException,\r
135                         XmlSchemaObject xsobj,\r
136                         object sender)\r
137                 {\r
138                         ValidationHandler.RaiseValidationEvent (handle,\r
139                                 innerException,\r
140                                 message,\r
141                                 xsobj,\r
142                                 sender,\r
143                                 null,\r
144                                 XmlSeverityType.Warning);\r
145                 }\r
146 \r
147                 internal virtual int Compile (ValidationEventHandler h, XmlSchema schema)\r
148                 {\r
149                         return 0;\r
150                 }\r
151 \r
152                 internal bool IsComplied (Guid compilationId)\r
153                 {\r
154                         return this.CompilationId == compilationId;\r
155                 }\r
156 \r
157                 internal virtual int Validate (ValidationEventHandler h, XmlSchema schema)\r
158                 {\r
159                         return 0;\r
160                 }\r
161 \r
162                 internal bool IsValidated (Guid validationId)\r
163                 {\r
164                         return this.ValidationId == validationId;\r
165                 }\r
166 \r
167                 // This method is used only by particles\r
168                 internal virtual void CopyInfo (XmlSchemaParticle obj)\r
169                 {\r
170                         obj.LineNumber = LineNumber;\r
171                         obj.LinePosition = LinePosition;\r
172                         obj.SourceUri = SourceUri;\r
173                         obj.errorCount = errorCount;\r
174                         // Other fields and properties may be useless for Particle.\r
175                 }\r
176         }\r
177 }