2004-05-31 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / Commons.Xml.Relaxng / Commons.Xml.Relaxng / RelaxngDatatypeProvider.cs
1 //\r
2 // RelaxngDatatypeProvider.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 \r
10 using System;\r
11 using System.Xml;\r
12 using System.Xml.Schema;\r
13 \r
14 namespace Commons.Xml.Relaxng\r
15 {\r
16         public abstract class RelaxngDatatypeProvider\r
17         {\r
18                 public abstract RelaxngDatatype GetDatatype (string name, string ns, RelaxngParamList parameters);\r
19         }\r
20 \r
21         internal class RelaxngNamespaceDatatypeProvider : RelaxngDatatypeProvider\r
22         {\r
23                 static RelaxngNamespaceDatatypeProvider instance;\r
24                 static RelaxngDatatype stringType = RelaxngString.Instance;\r
25                 static RelaxngDatatype tokenType = RelaxngToken.Instance;\r
26 \r
27                 static RelaxngNamespaceDatatypeProvider ()\r
28                 {\r
29                         instance = new RelaxngNamespaceDatatypeProvider ();\r
30                 }\r
31 \r
32                 public static RelaxngNamespaceDatatypeProvider Instance {\r
33                         get { return instance; }\r
34                 }\r
35 \r
36                 private RelaxngNamespaceDatatypeProvider () {}\r
37 \r
38                 public override RelaxngDatatype GetDatatype (string name, string ns, RelaxngParamList parameters)\r
39                 {\r
40                         if (ns != String.Empty)\r
41                                 throw new RelaxngException ("Not supported data type URI");\r
42                         if (parameters != null && parameters.Count > 0)\r
43                                 throw new RelaxngException ("Parameter is not allowed for this datatype: " + name);\r
44 \r
45                         switch (name) {\r
46                         case "string":\r
47                                 return stringType;\r
48                         case "token":\r
49                                 return tokenType;\r
50                         }\r
51                         return null;\r
52                 }\r
53         }\r
54 }\r