New test.
[mono.git] / mcs / class / Commons.Xml.Relaxng / Commons.Xml.Relaxng.Derivative / RdpObjects.cs
1 //
2 // Commons.Xml.Relaxng.Derivative.RdpObjects.cs
3 //
4 // Author:
5 //      Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
6 //
7 // 2003 Atsushi Enomoto "No rights reserved."
8 //
9 // Copyright (c) 2004 Novell Inc.
10 // All rights reserved
11 //
12
13 //
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
21 // 
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
24 // 
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 //
33
34 using System;
35 using System.Collections;
36 using System.Collections.Specialized;
37 using System.Xml;
38
39 namespace Commons.Xml.Relaxng.Derivative
40 {
41         ///
42         /// Datatype Related Classes
43         ///
44         public class RdpParamList : ArrayList
45         {
46                 public RdpParamList () : base ()
47                 {
48                 }
49         }
50
51         public class RdpParam
52         {
53                 public RdpParam (string localName, string value)
54                 {
55                         this.localName = localName;
56                         this.value = value;
57                 }
58
59                 string value;
60                 public string Value {
61                         get { return this.value; }
62                 }
63
64                 string localName;
65                 public string LocalName {
66                         get { return localName; }
67                 }
68         }
69
70         public class RdpDatatype
71         {
72                 //RelaxngDatatypeProvider provider;
73                 string localName;
74                 string ns;
75                 RelaxngDatatype datatype;
76
77                 public RdpDatatype (string ns, string localName, RelaxngParamList parameters, RelaxngDatatypeProvider provider)
78                 {
79                         this.ns = ns;
80                         this.localName = localName;
81                         //this.provider = provider;
82                         if (provider == null)
83                                 provider = RelaxngMergedProvider.DefaultProvider;
84                         datatype = provider.GetDatatype (localName, ns, parameters);
85                         if (datatype == null) {
86                                 throw new RelaxngException (String.Format ("Invalid datatype was found for namespace '{0}' and local name '{1}'", ns, localName));
87                         }
88                 }
89
90                 public string NamespaceURI {
91                         get { return ns; }
92                 }
93
94                 public string LocalName {
95                         get { return localName; }
96                 }
97
98                 public bool IsContextDependent {
99                         get { return datatype.IsContextDependent; }
100                 }
101
102                 public virtual bool IsAllowed (string value, XmlReader reader)
103                 {
104                         return datatype.IsValid (value, reader);
105                 }
106
107                 public virtual bool IsTypeEqual (string s1, string s2, XmlReader reader)
108                 {
109                         return datatype.CompareString (s1, s2, reader);
110                 }
111         }
112
113 }
114