Add MIT license to System.XML.DLL
[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                 protected XmlSchemaObject()\r
55                 {\r
56                         namespaces = new XmlSerializerNamespaces();\r
57                         unhandledAttributeList = null;\r
58                         CompilationId = Guid.Empty;\r
59                 }\r
60 \r
61                 [XmlIgnore]\r
62                 public int LineNumber \r
63                 { \r
64                         get{ return lineNumber; } \r
65                         set{ lineNumber = value; } \r
66                 }\r
67                 [XmlIgnore]\r
68                 public int LinePosition \r
69                 { \r
70                         get{ return linePosition; } \r
71                         set{ linePosition = value; } \r
72                 }\r
73                 [XmlIgnore]\r
74                 public string SourceUri \r
75                 { \r
76                         get{ return sourceUri; } \r
77                         set{ sourceUri = value; } \r
78                 }\r
79 \r
80                 // Undocumented Property\r
81                 [XmlNamespaceDeclarations]\r
82                 public XmlSerializerNamespaces Namespaces \r
83                 { \r
84                         get{ return namespaces; } \r
85                         set{ namespaces = value; } \r
86                 }\r
87 \r
88                 internal void error(ValidationEventHandler handle,string message)\r
89                 {\r
90                         errorCount++;\r
91                         error (handle, message, null, this, null);\r
92                 }\r
93                 internal void warn(ValidationEventHandler handle,string message)\r
94                 {\r
95                         warn (handle, message, null, this, null);\r
96                 }\r
97                 internal static void error(ValidationEventHandler handle, string message, Exception innerException)\r
98                 {\r
99                         error (handle, message, innerException, null, null);\r
100                 }\r
101                 internal static void warn(ValidationEventHandler handle, string message, Exception innerException)\r
102                 {\r
103                         warn (handle, message, innerException, null, null);\r
104                 }\r
105                 internal static void error(ValidationEventHandler handle,\r
106                         string message,\r
107                         Exception innerException,\r
108                         XmlSchemaObject xsobj,\r
109                         object sender)\r
110                 {\r
111                         ValidationHandler.RaiseValidationEvent (handle,\r
112                                 innerException,\r
113                                 message,\r
114                                 xsobj,\r
115                                 sender,\r
116                                 null,\r
117                                 XmlSeverityType.Error);\r
118                 }\r
119                 internal static void warn(ValidationEventHandler handle,\r
120                         string message,\r
121                         Exception innerException,\r
122                         XmlSchemaObject xsobj,\r
123                         object sender)\r
124                 {\r
125                         ValidationHandler.RaiseValidationEvent (handle,\r
126                                 innerException,\r
127                                 message,\r
128                                 xsobj,\r
129                                 sender,\r
130                                 null,\r
131                                 XmlSeverityType.Warning);\r
132                 }\r
133 \r
134                 internal virtual int Compile (ValidationEventHandler h, XmlSchema schema)\r
135                 {\r
136                         return 0;\r
137                 }\r
138 \r
139                 internal bool IsComplied (Guid compilationId)\r
140                 {\r
141                         return this.CompilationId == compilationId;\r
142                 }\r
143 \r
144                 internal virtual int Validate (ValidationEventHandler h, XmlSchema schema)\r
145                 {\r
146                         return 0;\r
147                 }\r
148 \r
149                 internal bool IsValidated (Guid validationId)\r
150                 {\r
151                         return this.ValidationId == validationId;\r
152                 }\r
153 \r
154                 // This method is used only by particles\r
155                 internal virtual void CopyInfo (XmlSchemaParticle obj)\r
156                 {\r
157                         obj.LineNumber = LineNumber;\r
158                         obj.LinePosition = LinePosition;\r
159                         obj.SourceUri = SourceUri;\r
160                         obj.errorCount = errorCount;\r
161                         // Other fields and properties may be useless for Particle.\r
162                 }\r
163         }\r
164 }