5 // Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
7 // (C)2003 Atsushi Enomoto
11 using System.Collections;
12 using System.Collections.Specialized;
13 using System.ComponentModel;
15 using System.Security.Policy;
16 using System.Xml.Schema;
17 using System.Xml.XPath;
19 namespace System.Xml.Schema
22 public class XmlSchemaSet
24 internal class XmlSchemaSet
27 XmlNameTable nameTable;
28 XmlResolver xmlResolver;
31 XmlSchemaObjectTable attributes;
32 XmlSchemaObjectTable elements;
33 XmlSchemaObjectTable types;
34 XmlSchemaCollection col;
38 internal Guid CompilationId;
\r
40 public XmlSchemaSet () : this (new NameTable ())
44 public XmlSchemaSet (XmlNameTable nameTable)
46 this.nameTable = nameTable;
47 schemas = new Hashtable ();
48 attributes = new XmlSchemaObjectTable ();
49 elements = new XmlSchemaObjectTable ();
50 types = new XmlSchemaObjectTable ();
51 CompilationId = Guid.NewGuid ();
54 public event ValidationEventHandler ValidationEventHandler;
57 get { return schemas.Count; }
60 public XmlSchemaObjectTable GlobalAttributes {
61 get { return attributes; }
64 public XmlSchemaObjectTable GlobalElements {
65 get { return elements; }
68 public XmlSchemaObjectTable GlobalTypes {
72 public bool IsCompiled {
73 get { return isCompiled; }
76 public XmlNameTable NameTable {
77 get { return nameTable; }
80 // This is mainly used for event delegating
81 internal XmlSchemaCollection SchemaCollection {
86 public XmlResolver XmlResolver {
87 set { xmlResolver = value; }
90 public XmlSchema Add (string targetNamespace, string url)
92 XmlTextReader r = null;
94 r = new XmlTextReader (url);
95 return Add (targetNamespace, r);
102 [MonoTODO ("Check how targetNamespace is used")]
103 public XmlSchema Add (string targetNamespace, XmlReader reader)
105 return Add (XmlSchema.Read (reader, null));
108 [MonoTODO ("Check the exact behavior when namespaces are in conflict")]
109 public void Add (XmlSchemaSet schemaSet)
111 foreach (XmlSchema schema in schemaSet.schemas)
112 schemas.Add (schema.TargetNamespace, schema);
115 [MonoTODO ("Check the exact behavior when namespaces are in conflict")]
116 public XmlSchema Add (XmlSchema schema)
118 XmlSchema existing = schemas [GetSafeNs (schema.TargetNamespace)] as XmlSchema;
119 if (existing != null)
121 schemas.Add (GetSafeNs (schema.TargetNamespace), schema);
125 public void Compile ()
127 throw new NotImplementedException ();
130 public bool Contains (string targetNamespace)
132 return schemas.ContainsKey (targetNamespace);
135 public bool Contains (XmlSchema targetNamespace)
137 return schemas.Contains (targetNamespace);
140 public void CopyTo (XmlSchema[] array, int index)
142 schemas.CopyTo (array, index);
145 internal void CopyTo (Array array, int index)
147 schemas.CopyTo (array, index);
150 internal XmlSchema Get (string ns)
152 return (XmlSchema) schemas [GetSafeNs (ns)];
155 internal IEnumerator GetEnumerator()
\r
157 return schemas.GetEnumerator();
\r
160 string GetSafeNs (string ns)
\r
162 return ns == null ? "" : ns;
\r
165 internal void OnValidationError (object o, ValidationEventArgs e)
168 col.OnValidationError (o, e);
169 if (ValidationEventHandler != null)
170 ValidationEventHandler (o, e);
171 else if (e.Severity == XmlSeverityType.Error)
175 [MonoTODO ("Check exact behavior")]
176 public XmlSchema Remove (XmlSchema schema)
178 schemas.Remove (schema);
182 public ArrayList Schemas ()
184 return new ArrayList (schemas);
188 public ArrayList Schemas (string targetNamespace)
190 throw new NotImplementedException ();