Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2003-07-19 22:35:33 +0400
committerAtsushi Eno <atsushieno@gmail.com>2003-07-19 22:35:33 +0400
commit39377e5a7b9bd9b3d55890ade643cde5ef6d47cf (patch)
tree53f64956977a5fd9f81058b9edf342d1cbbf20e4
parenta2ff2914af31d6695bc3b4bcacfc47a6df030970 (diff)
2003-07-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* BuiltInDatatypes.cs, XmlSchemaDatatype.cs : Added decimal and its derived datatypes. Added abstract XsdAnySimpleType. svn path=/trunk/mcs/; revision=16434
-rw-r--r--mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs269
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/ChangeLog6
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs53
3 files changed, 306 insertions, 22 deletions
diff --git a/mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs b/mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs
index 0cf1be2b47a..6622c15d758 100644
--- a/mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs
+++ b/mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs
@@ -21,8 +21,28 @@ namespace Mono.Xml.Schema
Collapse
}
+ public enum XsdOrderedFacet
+ {
+ False,
+ Partial,
+ Total
+ }
+
+ public abstract class XsdAnySimpleType : XmlSchemaDatatype
+ {
+ // Fundamental Facets
+ public abstract bool Bounded { get; }
+
+ public abstract bool Finite { get; }
+
+ public abstract bool Numeric { get; }
+
+ public abstract XsdOrderedFacet Ordered { get; }
+
+ }
+
// xs:string
- public class XsdString : XmlSchemaDatatype
+ public class XsdString : XsdAnySimpleType
{
internal XsdString ()
{
@@ -43,17 +63,17 @@ namespace Mono.Xml.Schema
}
// Fundamental Facets
- public virtual bool Bounded {
+ public override bool Bounded {
get { return false; }
}
- public virtual bool Finite {
+ public override bool Finite {
get { return false; }
}
- public virtual bool Numeric {
+ public override bool Numeric {
get { return false; }
}
- public virtual bool Ordered {
- get { return false; }
+ public override XsdOrderedFacet Ordered {
+ get { return XsdOrderedFacet.False; }
}
// Constraining Facets
@@ -287,7 +307,7 @@ namespace Mono.Xml.Schema
}
// xs:NOTATION
- public class XsdNotation : XmlSchemaDatatype
+ public class XsdNotation : XsdAnySimpleType
{
internal XsdNotation ()
{
@@ -308,17 +328,17 @@ namespace Mono.Xml.Schema
}
// Fundamental Facets
- public virtual bool Bounded {
+ public override bool Bounded {
get { return false; }
}
- public virtual bool Finite {
+ public override bool Finite {
get { return false; }
}
- public virtual bool Numeric {
+ public override bool Numeric {
get { return false; }
}
- public virtual bool Ordered {
- get { return false; }
+ public override XsdOrderedFacet Ordered {
+ get { return XsdOrderedFacet.False; }
}
// Constraining Facets
@@ -332,14 +352,191 @@ namespace Mono.Xml.Schema
public ICollection Enumeration;
}
- // xs:unsignedByte
- public class XsdUnsignedByte : XmlSchemaDatatype
+ // xs:decimal
+ public class XsdDecimal : XsdAnySimpleType
{
+ internal XsdDecimal ()
+ {
+ }
+
public override XmlTokenizedType TokenizedType {
get { return XmlTokenizedType.CDATA; }
}
public override Type ValueType {
+ get { return typeof (decimal); }
+ }
+
+ public override object ParseValue (string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr)
+ {
+ return XmlConvert.ToDecimal (this.Normalize (s));
+ }
+
+ // Fundamental Facets
+ public override bool Bounded {
+ get { return false; }
+ }
+ public override bool Finite {
+ get { return false; }
+ }
+ public override bool Numeric {
+ get { return true; }
+ }
+ public override XsdOrderedFacet Ordered {
+ get { return XsdOrderedFacet.Total; }
+ }
+
+ // Constraining Facets
+ public bool HasLengthFacet;
+ public bool HasMaxLengthFacet;
+ public bool HasMinLengthFacet;
+ public int Length;
+ public int MaxLength;
+ public int MinLength;
+ public string Pattern;
+ public ICollection Enumeration;
+ }
+
+ // xs:integer
+ public class XsdInteger : XsdDecimal
+ {
+ // Here it may be bigger than int's (or long's) MaxValue.
+ public override Type ValueType {
+ get { return typeof (decimal); }
+ }
+
+ public override object ParseValue (string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr)
+ {
+ return XmlConvert.ToDecimal (Normalize (s));
+ }
+ }
+
+ // xs:Long
+ public class XsdLong : XsdNonNegativeInteger
+ {
+ public override Type ValueType {
+ get { return typeof (long); }
+ }
+
+ public override object ParseValue (string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr)
+ {
+ return XmlConvert.ToInt64 (Normalize (s));
+ }
+ }
+
+ // xs:Int
+ public class XsdInt : XsdLong
+ {
+ public override Type ValueType {
+ get { return typeof (int); }
+ }
+
+ public override object ParseValue (string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr)
+ {
+ return XmlConvert.ToInt32 (Normalize (s));
+ }
+ }
+
+
+ // xs:Short
+ public class XsdShort : XsdInt
+ {
+ public override Type ValueType {
+ get { return typeof (short); }
+ }
+
+ public override object ParseValue (string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr)
+ {
+ return XmlConvert.ToInt16 (Normalize (s));
+ }
+ }
+
+ // xs:Byte
+ public class XsdByte : XsdShort
+ {
+ public override Type ValueType {
+ get { return typeof (byte); }
+ }
+
+ public override object ParseValue (string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr)
+ {
+ return XmlConvert.ToByte (Normalize (s));
+ }
+ }
+
+ // xs:nonNegativeInteger
+ [CLSCompliant (false)]
+ public class XsdNonNegativeInteger : XsdInteger
+ {
+ public override Type ValueType {
+ get { return typeof (decimal); }
+ }
+
+ [CLSCompliant (false)]
+ public override object ParseValue (string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr)
+ {
+ return XmlConvert.ToDecimal (Normalize (s));
+ }
+ }
+
+ // xs:unsignedLong
+ [CLSCompliant (false)]
+ public class XsdUnsignedLong : XsdNonNegativeInteger
+ {
+ public override Type ValueType {
+ get { return typeof (ulong); }
+ }
+
+ public override object ParseValue (string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr)
+ {
+ return XmlConvert.ToUInt64 (Normalize (s));
+ }
+ }
+
+ // xs:unsignedInt
+ [CLSCompliant (false)]
+ public class XsdUnsignedInt : XsdUnsignedLong
+ {
+ public override Type ValueType {
+ get { return typeof (uint); }
+ }
+
+ public override object ParseValue (string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr)
+ {
+ return XmlConvert.ToUInt32 (Normalize (s));
+ }
+ }
+
+
+ // xs:unsignedShort
+ [CLSCompliant (false)]
+ public class XsdUnsignedShort : XsdUnsignedInt
+ {
+ public override Type ValueType {
+ get { return typeof (ushort); }
+ }
+
+ public override object ParseValue (string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr)
+ {
+ return XmlConvert.ToUInt16 (Normalize (s));
+ }
+ }
+
+ // xs:unsignedByte
+ [CLSCompliant (false)]
+ public class XsdUnsignedByte : XsdUnsignedShort
+ {
+ public override Type ValueType {
get { return typeof (byte); }
}
@@ -350,4 +547,48 @@ namespace Mono.Xml.Schema
}
}
+ // xs:positiveInteger
+ public class XsdPositiveInteger : XsdNonNegativeInteger
+ {
+ // It returns decimal, instead of int or long.
+ // Maybe MS developers thought about big integer...
+ public override Type ValueType {
+ get { return typeof (decimal); }
+ }
+
+ public override object ParseValue (string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr)
+ {
+ return XmlConvert.ToDecimal (Normalize (s));
+ }
+ }
+
+ // xs:nonPositiveInteger
+ public class XsdNonPositiveInteger : XsdInteger
+ {
+ public override Type ValueType {
+ get { return typeof (decimal); }
+ }
+
+ public override object ParseValue (string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr)
+ {
+ return XmlConvert.ToDecimal (Normalize (s));
+ }
+ }
+
+ // xs:negativeInteger
+ public class XsdNegativeInteger : XsdNonPositiveInteger
+ {
+ public override Type ValueType {
+ get { return typeof (decimal); }
+ }
+
+ public override object ParseValue (string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr)
+ {
+ return XmlConvert.ToDecimal (Normalize (s));
+ }
+ }
+
}
diff --git a/mcs/class/System.XML/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
index 67fd5fae505..c28a08b0dfc 100755
--- a/mcs/class/System.XML/System.Xml.Schema/ChangeLog
+++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
@@ -1,3 +1,9 @@
+2003-07-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * BuiltInDatatypes.cs, XmlSchemaDatatype.cs :
+ Added decimal and its derived datatypes.
+ Added abstract XsdAnySimpleType.
+
2003-07-15 Lluis Sanchez Gual <lluis@ximian.com>
* BuiltInDatatype.cs,
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs
index f1bc7ecee03..80f8afcda7f 100755
--- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs
@@ -55,12 +55,11 @@ namespace System.Xml.Schema
}
//TODO: This should return all appropriate inbuilt type
- internal static XmlSchemaDatatype GetType (XmlQualifiedName qname)
+ internal static XmlSchemaDatatype FromName (XmlQualifiedName qname)
{
- if (qname.Namespace == "http://www.w3.org/2001/XMLSchema" ||
- qname.Namespace == String.Empty)
- return FromName (qname.Name);
- throw new NotImplementedException ();
+ if (qname.Namespace != XmlSchema.Namespace)
+ throw new InvalidOperationException ("Namespace " + XmlSchema.Namespace + " is required.");
+ return FromName (qname.Name);
}
//TODO: This should return all appropriate inbuilt type
@@ -95,8 +94,34 @@ namespace System.Xml.Schema
return datatypeEntities;
case "NOTATION":
return datatypeNotation;
+ case "decimal":
+ return datatypeDecimal;
+ case "integer":
+ return datatypeInteger;
+ case "long":
+ return datatypeLong;
+ case "int":
+ return datatypeInt;
+ case "short":
+ return datatypeShort;
+ case "byte":
+ return datatypeByte;
+ case "nonPositiveInteger":
+ return datatypeNonPositiveInteger;
+ case "negativeInteger":
+ return datatypeNegativeInteger;
+ case "nonNegativeInteger":
+ return datatypeNonNegativeInteger;
+ case "unsignedLong":
+ return datatypeUnsignedLong;
+ case "unsignedInt":
+ return datatypeUnsignedInt;
+ case "unsignedShort":
+ return datatypeUnsignedShort;
case "unsignedByte":
- return datatypeUnsignedBye;
+ return datatypeUnsignedByte;
+ case "positiveInteger":
+ return datatypePositiveInteger;
default:
throw new NotImplementedException ("Unknown type: " + localName);
}
@@ -116,7 +141,19 @@ namespace System.Xml.Schema
private static XsdEntity datatypeEntity = new XsdEntity ();
private static XsdEntities datatypeEntities = new XsdEntities ();
private static XsdNotation datatypeNotation = new XsdNotation ();
- private static XsdUnsignedByte datatypeUnsignedBye = new XsdUnsignedByte ();
-
+ private static XsdDecimal datatypeDecimal = new XsdDecimal ();
+ private static XsdInteger datatypeInteger = new XsdInteger ();
+ private static XsdLong datatypeLong = new XsdLong ();
+ private static XsdInt datatypeInt = new XsdInt ();
+ private static XsdShort datatypeShort = new XsdShort ();
+ private static XsdByte datatypeByte = new XsdByte ();
+ private static XsdNonNegativeInteger datatypeNonNegativeInteger = new XsdNonNegativeInteger ();
+ private static XsdPositiveInteger datatypePositiveInteger = new XsdPositiveInteger ();
+ private static XsdUnsignedLong datatypeUnsignedLong = new XsdUnsignedLong ();
+ private static XsdUnsignedInt datatypeUnsignedInt = new XsdUnsignedInt ();
+ private static XsdUnsignedShort datatypeUnsignedShort = new XsdUnsignedShort ();
+ private static XsdUnsignedByte datatypeUnsignedByte = new XsdUnsignedByte ();
+ private static XsdNonPositiveInteger datatypeNonPositiveInteger = new XsdNonPositiveInteger ();
+ private static XsdNegativeInteger datatypeNegativeInteger = new XsdNegativeInteger ();
}
}