2 // Commons.Xml.Relaxng.Derivative.RdpObjects.cs
\r
5 // Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
\r
7 // 2003 Atsushi Enomoto "No rights reserved."
\r
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:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
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.
32 using System.Collections;
\r
33 using System.Collections.Specialized;
\r
36 namespace Commons.Xml.Relaxng.Derivative
\r
39 /// Datatype Related Classes
\r
41 public class RdpParamList : ArrayList
\r
43 public RdpParamList () : base ()
\r
48 public class RdpParam
\r
50 public RdpParam (string localName, string value)
\r
52 this.localName = localName;
\r
57 public string Value {
\r
58 get { return this.value; }
\r
62 public string LocalName {
\r
63 get { return localName; }
\r
67 public class RdpDatatype
\r
69 RelaxngDatatypeProvider provider;
\r
72 RelaxngDatatype datatype;
\r
74 public RdpDatatype (string ns, string localName, RelaxngParamList parameters, RelaxngDatatypeProvider provider)
\r
77 this.localName = localName;
\r
78 this.provider = provider;
\r
79 if (provider == null)
\r
80 provider = RelaxngMergedProvider.DefaultProvider;
\r
81 datatype = provider.GetDatatype (localName, ns, parameters);
\r
82 if (datatype == null) {
\r
83 throw new RelaxngException ("Invalid datatype was found.");
\r
84 // datatype = RelaxngString.Instance;
\r
88 public string NamespaceURI {
\r
92 public string LocalName {
\r
93 get { return localName; }
\r
96 public virtual bool IsAllowed (string value, XmlReader reader)
\r
98 return datatype.IsValid (value, reader);
\r
101 static char [] wsChars = new char [] {' ', '\n', '\r', '\t'};
\r
103 public virtual bool IsTypeEqual (string s1, string s2, XmlReader reader)
\r
105 return datatype.CompareString (s1, s2, reader);
\r
112 /// ChildNode Classes
\r
114 public abstract class RdpChildNode
\r
117 public virtual bool IsNonWhitespaceText {
\r
118 get { return false; }
\r
122 public class RdpTextChild : RdpChildNode
\r
124 public RdpTextChild (string text)
\r
130 public string Text {
\r
131 get { return text; }
\r
134 public override bool IsNonWhitespaceText {
\r
135 get { return RdpUtil.Whitespace (text); }
\r
139 public class RdpElementChild : RdpChildNode
\r
141 public RdpElementChild (string name, string ns, RdpContext ctx, RdpAttributes attributes, RdpChildNodes childNodes)
\r
146 this.attributes = attributes;
\r
147 this.childNodes = childNodes;
\r
151 public string LocalName {
\r
152 get { return name; }
\r
156 public string NamespaceURI {
\r
161 public RdpContext Context {
\r
162 get { return ctx; }
\r
165 RdpAttributes attributes;
\r
166 public RdpAttributes Attributes {
\r
167 get { return attributes; }
\r
170 RdpChildNodes childNodes;
\r
171 public RdpChildNodes ChildNodes {
\r
172 get { return childNodes; }
\r
178 public class RdpChildNodes : ArrayList
\r
180 public RdpChildNodes () : base ()
\r
185 public class RdpAttributes : ArrayList
\r
187 public RdpAttributes () : base ()
\r
192 public class RdpAttributeNode : RdpChildNode
\r
194 public RdpAttributeNode (string name, string ns, string value) : base ()
\r
198 this.value = value;
\r
202 public string Value {
\r
203 get { return value; }
\r
207 public string LocalName {
\r
208 get { return name; }
\r
212 public string NamespaceURI {
\r