5 // Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
7 // (C)2003 Atsushi Enomoto
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Collections;
33 using System.Collections.Specialized;
34 using System.ComponentModel;
36 using System.Security.Policy;
37 using System.Xml.Schema;
38 using System.Xml.XPath;
40 namespace System.Xml.Schema
43 public class XmlSchemaSet
45 internal class XmlSchemaSet
48 XmlNameTable nameTable;
49 XmlResolver xmlResolver;
52 XmlSchemaObjectTable attributes;
53 XmlSchemaObjectTable elements;
54 XmlSchemaObjectTable types;
55 XmlSchemaCollection col;
59 internal Guid CompilationId;
\r
61 public XmlSchemaSet () : this (new NameTable ())
65 public XmlSchemaSet (XmlNameTable nameTable)
67 this.nameTable = nameTable;
68 schemas = new Hashtable ();
69 attributes = new XmlSchemaObjectTable ();
70 elements = new XmlSchemaObjectTable ();
71 types = new XmlSchemaObjectTable ();
72 CompilationId = Guid.NewGuid ();
75 public event ValidationEventHandler ValidationEventHandler;
78 get { return schemas.Count; }
81 public XmlSchemaObjectTable GlobalAttributes {
82 get { return attributes; }
85 public XmlSchemaObjectTable GlobalElements {
86 get { return elements; }
89 public XmlSchemaObjectTable GlobalTypes {
93 public bool IsCompiled {
94 get { return isCompiled; }
97 public XmlNameTable NameTable {
98 get { return nameTable; }
101 // This is mainly used for event delegating
102 internal XmlSchemaCollection SchemaCollection {
107 public XmlResolver XmlResolver {
108 set { xmlResolver = value; }
111 public XmlSchema Add (string targetNamespace, string url)
113 XmlTextReader r = null;
115 r = new XmlTextReader (url);
116 return Add (targetNamespace, r);
123 [MonoTODO ("Check how targetNamespace is used")]
124 public XmlSchema Add (string targetNamespace, XmlReader reader)
126 return Add (XmlSchema.Read (reader, null));
129 [MonoTODO ("Check the exact behavior when namespaces are in conflict")]
130 public void Add (XmlSchemaSet schemaSet)
132 foreach (XmlSchema schema in schemaSet.schemas)
133 schemas.Add (schema.TargetNamespace, schema);
136 [MonoTODO ("Check the exact behavior when namespaces are in conflict")]
137 public XmlSchema Add (XmlSchema schema)
139 XmlSchema existing = schemas [GetSafeNs (schema.TargetNamespace)] as XmlSchema;
140 if (existing != null)
142 schemas.Add (GetSafeNs (schema.TargetNamespace), schema);
147 public void Compile ()
149 throw new NotImplementedException ();
152 public bool Contains (string targetNamespace)
154 return schemas.ContainsKey (targetNamespace);
157 public bool Contains (XmlSchema targetNamespace)
159 return schemas.Contains (targetNamespace);
162 public void CopyTo (XmlSchema[] array, int index)
164 schemas.CopyTo (array, index);
167 internal void CopyTo (Array array, int index)
169 schemas.CopyTo (array, index);
172 internal XmlSchema Get (string ns)
174 return (XmlSchema) schemas [GetSafeNs (ns)];
177 internal IEnumerator GetEnumerator ()
\r
179 return schemas.GetEnumerator ();
\r
182 string GetSafeNs (string ns)
\r
184 return ns == null ? "" : ns;
\r
187 internal void OnValidationError (object o, ValidationEventArgs e)
190 col.OnValidationError (o, e);
191 if (ValidationEventHandler != null)
192 ValidationEventHandler (o, e);
193 else if (e.Severity == XmlSeverityType.Error)
197 [MonoTODO ("Check exact behavior")]
198 public XmlSchema Remove (XmlSchema schema)
200 schemas.Remove (schema);
205 public bool RemoveRecursive (XmlSchema schema)
207 throw new NotImplementedException ();
211 public XmlSchema Reprocess (XmlSchema schema)
213 throw new NotImplementedException ();
216 public ArrayList Schemas ()
218 return new ArrayList (schemas.Values);
222 public ArrayList Schemas (string targetNamespace)
224 throw new NotImplementedException ();