-//\r
-// Commons.Xml.Relaxng.Derivative.RdpObjects.cs\r
-//\r
-// Author:\r
-// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>\r
-//\r
-// 2003 Atsushi Enomoto "No rights reserved."\r
-//\r
-\r
-using System;\r
-using System.Collections;\r
-using System.Collections.Specialized;\r
-using System.Xml;\r
-\r
-namespace Commons.Xml.Relaxng.Derivative\r
-{\r
- ///\r
- /// Context Class\r
- ///\r
- public class RdpContext : ICloneable\r
- {\r
- public RdpContext ()\r
- {\r
- }\r
-\r
- public object Clone ()\r
- {\r
- return new RdpContext ();\r
- }\r
- }\r
-\r
- ///\r
- /// Datatype Related Classes\r
- ///\r
- public class RdpParamList : ArrayList\r
- {\r
- public RdpParamList () : base ()\r
- {\r
- }\r
- }\r
-\r
- public class RdpParam : ICloneable\r
- {\r
- public RdpParam (string localName, string value)\r
- {\r
- this.localName = localName;\r
- this.value = value;\r
- }\r
-\r
- string value;\r
- public string Value {\r
- get { return this.value; }\r
- }\r
-\r
- string localName;\r
- public string LocalName {\r
- get { return localName; }\r
- }\r
-\r
- public object Clone ()\r
- {\r
- return new RdpParam (this.localName, this.value);\r
- }\r
- }\r
-\r
- public class RdpDatatype : ICloneable\r
- {\r
- public RdpDatatype (string ns, string localName)\r
- {\r
- this.ns = ns;\r
- this.localName = localName;\r
- }\r
-\r
- string ns;\r
- public string NamespaceURI {\r
- get { return ns; }\r
- }\r
-\r
- string localName;\r
- public string LocalName {\r
- get { return localName; }\r
- }\r
-\r
- public virtual bool IsAllowed (RdpParamList pl, string value)\r
- {\r
- if (ns == String.Empty && localName == "string")\r
- return true;\r
- else if (ns == String.Empty && localName == "token")\r
- return true;\r
- else\r
- return true;\r
-// throw new NotSupportedException ("non-supported datatype validation.");\r
- }\r
-\r
- public virtual bool IsTypeEqual (string s1, RdpContext ctx1, string s2)\r
- {\r
- if (ns == String.Empty && localName == "string")\r
- return s1 == s2;\r
- else if (ns == String.Empty && localName == "token")\r
- return NormalizeWhitespace (s1) ==\r
- NormalizeWhitespace (s2);\r
- else\r
- throw new NotSupportedException ("non-supported datatype validation.");\r
- }\r
-\r
- public string NormalizeWhitespace (string s)\r
- {\r
- return String.Join (" ", s.Split (RdpUtil.WhitespaceChars));\r
- }\r
-\r
- public object Clone ()\r
- {\r
- return new RdpDatatype (ns, localName);\r
- }\r
- }\r
-\r
- ///\r
- /// ChildNode Classes\r
- ///\r
- public abstract class RdpChildNode\r
- {\r
- // Strip\r
- public virtual bool IsNonWhitespaceText {\r
- get { return false; }\r
- }\r
- }\r
-\r
- public class RdpTextChild : RdpChildNode\r
- {\r
- public RdpTextChild (string text)\r
- {\r
- this.text = text;\r
- }\r
-\r
- string text;\r
- public string Text {\r
- get { return text; }\r
- }\r
-\r
- public override bool IsNonWhitespaceText {\r
- get { return RdpUtil.Whitespace (text); }\r
- }\r
- }\r
-\r
- public class RdpElementChild : RdpChildNode\r
- {\r
- public RdpElementChild (string name, string ns, RdpContext ctx, RdpAttributes attributes, RdpChildNodes childNodes)\r
- {\r
- this.name = name;\r
- this.ns = ns;\r
- this.ctx = ctx;\r
- this.attributes = attributes;\r
- this.childNodes = childNodes;\r
- }\r
-\r
- string name;\r
- public string LocalName {\r
- get { return name; }\r
- }\r
-\r
- string ns;\r
- public string NamespaceURI {\r
- get { return ns; }\r
- }\r
-\r
- RdpContext ctx;\r
- public RdpContext Context {\r
- get { return ctx; }\r
- }\r
-\r
- RdpAttributes attributes;\r
- public RdpAttributes Attributes {\r
- get { return attributes; }\r
- }\r
-\r
- RdpChildNodes childNodes;\r
- public RdpChildNodes ChildNodes {\r
- get { return childNodes; }\r
- }\r
- }\r
-\r
- public class RdpChildNodes : ArrayList\r
- {\r
- public RdpChildNodes () : base ()\r
- {\r
- }\r
- }\r
-\r
- public class RdpAttributes : ArrayList\r
- {\r
- public RdpAttributes () : base ()\r
- {\r
- }\r
- }\r
-\r
- public class RdpAttributeNode : RdpChildNode\r
- {\r
- public RdpAttributeNode (string name, string ns, string value) : base ()\r
- {\r
- this.name = name;\r
- this.ns = ns;\r
- this.value = value;\r
- }\r
-\r
- string value;\r
- public string Value {\r
- get { return value; }\r
- }\r
-\r
- string name;\r
- public string LocalName {\r
- get { return name; }\r
- }\r
-\r
- string ns;\r
- public string NamespaceURI {\r
- get { return ns; }\r
- }\r
- }\r
-}\r
-\r
+//
+// Commons.Xml.Relaxng.Derivative.RdpObjects.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+// 2003 Atsushi Enomoto "No rights reserved."
+//
+// Copyright (c) 2004 Novell Inc.
+// All rights reserved
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Xml;
+
+namespace Commons.Xml.Relaxng.Derivative
+{
+ ///
+ /// Datatype Related Classes
+ ///
+ public class RdpParamList : ArrayList
+ {
+ public RdpParamList () : base ()
+ {
+ }
+ }
+
+ public class RdpParam
+ {
+ public RdpParam (string localName, string value)
+ {
+ this.localName = localName;
+ this.value = value;
+ }
+
+ string value;
+ public string Value {
+ get { return this.value; }
+ }
+
+ string localName;
+ public string LocalName {
+ get { return localName; }
+ }
+ }
+
+ public class RdpDatatype
+ {
+ //RelaxngDatatypeProvider provider;
+ string localName;
+ string ns;
+ RelaxngDatatype datatype;
+
+ public RdpDatatype (string ns, string localName, RelaxngParamList parameters, RelaxngDatatypeProvider provider)
+ {
+ this.ns = ns;
+ this.localName = localName;
+ //this.provider = provider;
+ if (provider == null)
+ provider = RelaxngMergedProvider.DefaultProvider;
+ datatype = provider.GetDatatype (localName, ns, parameters);
+ if (datatype == null) {
+ throw new RelaxngException (String.Format ("Invalid datatype was found for namespace '{0}' and local name '{1}'", ns, localName));
+ }
+ }
+
+ public string NamespaceURI {
+ get { return ns; }
+ }
+
+ public string LocalName {
+ get { return localName; }
+ }
+
+ public bool IsContextDependent {
+ get { return datatype.IsContextDependent; }
+ }
+
+ public virtual bool IsAllowed (string value, XmlReader reader)
+ {
+ return datatype.IsValid (value, reader);
+ }
+
+ public virtual bool IsTypeEqual (string s1, string s2, XmlReader reader)
+ {
+ return datatype.CompareString (s1, s2, reader);
+ }
+ }
+
+}
+