615b7d9a8a0676201bc4c34672583254ef1b90b3
[mono.git] / mcs / class / Commons.Xml.Relaxng / Commons.Xml.Relaxng / RelaxngMergedProvider.cs
1 //\r
2 // RelaxngMergedProvider.cs\r
3 //\r
4 // Author:\r
5 //      Atsushi Enomoto <atsushi@ximian.com>\r
6 //\r
7 // (C)2004 Novell Inc.\r
8 //\r
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 using System;\r
31 using System.Collections;\r
32 using Commons.Xml.Relaxng.XmlSchema;\r
33 \r
34 using XSchema = System.Xml.Schema.XmlSchema;\r
35 \r
36 namespace Commons.Xml.Relaxng\r
37 {\r
38         public class RelaxngMergedProvider : RelaxngDatatypeProvider\r
39         {\r
40                 static RelaxngMergedProvider defaultProvider;\r
41                 static RelaxngMergedProvider ()\r
42                 {\r
43                         RelaxngMergedProvider p = new RelaxngMergedProvider ();\r
44 #if !PNET\r
45                         p ["http://www.w3.org/2001/XMLSchema-datatypes"] = XsdDatatypeProvider.Instance;\r
46                         p [XSchema.Namespace] = XsdDatatypeProvider.Instance;\r
47 #endif\r
48                         p [String.Empty] = RelaxngNamespaceDatatypeProvider.Instance;\r
49                         defaultProvider = p;\r
50                 }\r
51 \r
52                 public static RelaxngMergedProvider DefaultProvider {\r
53                         get { return defaultProvider; }\r
54                 }\r
55 \r
56                 Hashtable table = new Hashtable ();\r
57 \r
58                 public RelaxngMergedProvider ()\r
59                 {\r
60                 }\r
61 \r
62                 public RelaxngDatatypeProvider this [string ns] {\r
63                         get { return table [ns] as RelaxngDatatypeProvider; }\r
64                         set { table [ns] = value; }\r
65                 }\r
66 \r
67                 public override RelaxngDatatype GetDatatype (string name, string ns, RelaxngParamList parameters) {\r
68                         // TODO: parameter support (write schema and get type)\r
69 \r
70                         RelaxngDatatypeProvider p = table [ns] as RelaxngDatatypeProvider;\r
71                         if (p == null)\r
72                                 return null;\r
73                         return p.GetDatatype (name, ns, parameters);\r
74                 }\r
75         }\r
76 }\r