(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Mono.Xml.Ext / Mono.Xml / InternalPool.cs
blobe48f8f1c1ac30f7f7c1bbb032f7d2e1f73ef25c0
2 #if NET_2_0
4 using System;
5 using System.Collections;
6 using System.Xml;
7 using System.Xml.Schema;
9 namespace Mono.Xml
11 internal class InternalPool
13 public const string XdtNamespace = "http://www.w3.org/2003/11/xpath-datatypes";
15 internal static readonly XmlQualifiedName XsAnyTypeName
16 = new XmlQualifiedName ("any", XmlSchema.Namespace);
17 internal static readonly XmlSchemaComplexType XsAnyType
18 = XmlSchemaType.GetBuiltInComplexType (XsAnyTypeName);
20 internal static readonly XmlQualifiedName XdtUntypedAtomicName
21 = new XmlQualifiedName ("untypedAtomic", XdtNamespace);
22 internal static readonly XmlSchemaSimpleType XdtUntypedAtomic
23 = XmlSchemaType.GetBuiltInSimpleType (XdtUntypedAtomicName);
25 internal static readonly XmlQualifiedName XsStringName
26 = new XmlQualifiedName ("string", XmlSchema.Namespace);
27 internal static readonly XmlSchemaSimpleType XsString
28 = XmlSchemaType.GetBuiltInSimpleType (XsStringName);
29 internal static readonly XmlQualifiedName XsNormalizedStringName
30 = new XmlQualifiedName ("normalizedString", XmlSchema.Namespace);
31 internal static readonly XmlSchemaSimpleType XsNormalizedString
32 = XmlSchemaType.GetBuiltInSimpleType (XsNormalizedStringName);
33 internal static readonly XmlQualifiedName XsTokenName
34 = new XmlQualifiedName ("token", XmlSchema.Namespace);
35 internal static readonly XmlSchemaSimpleType XsToken
36 = XmlSchemaType.GetBuiltInSimpleType (XsTokenName);
37 internal static readonly XmlQualifiedName XsIDName
38 = new XmlQualifiedName ("ID", XmlSchema.Namespace);
39 internal static readonly XmlSchemaSimpleType XsID
40 = XmlSchemaType.GetBuiltInSimpleType (XsIDName);
41 internal static readonly XmlQualifiedName XsIDREFName
42 = new XmlQualifiedName ("IDREF", XmlSchema.Namespace);
43 internal static readonly XmlSchemaSimpleType XsIDREF
44 = XmlSchemaType.GetBuiltInSimpleType (XsIDREFName);
45 internal static readonly XmlQualifiedName XsIDREFSName
46 = new XmlQualifiedName ("IDREFS", XmlSchema.Namespace);
47 internal static readonly XmlSchemaSimpleType XsIDREFS
48 = XmlSchemaType.GetBuiltInSimpleType (XsIDREFSName);
49 internal static readonly XmlQualifiedName XsQNameName
50 = new XmlQualifiedName ("QName", XmlSchema.Namespace);
51 internal static readonly XmlSchemaSimpleType XsQName
52 = XmlSchemaType.GetBuiltInSimpleType (XsQNameName);
53 internal static readonly XmlQualifiedName XsBooleanName
54 = new XmlQualifiedName ("boolean", XmlSchema.Namespace);
55 internal static readonly XmlSchemaSimpleType XsBoolean
56 = XmlSchemaType.GetBuiltInSimpleType (XsBooleanName);
58 internal static readonly XmlQualifiedName XsDurationName
59 = new XmlQualifiedName ("duration", XmlSchema.Namespace);
60 internal static readonly XmlSchemaSimpleType XsDuration
61 = XmlSchemaType.GetBuiltInSimpleType (XsDurationName);
62 internal static readonly XmlQualifiedName XdtDayTimeDurationName
63 = new XmlQualifiedName ("dayTimeDuration", InternalPool.XdtNamespace);
64 internal static readonly XmlSchemaSimpleType XdtDayTimeDuration
65 = XmlSchemaType.GetBuiltInSimpleType (XdtDayTimeDurationName);
66 internal static readonly XmlQualifiedName XdtYearMonthDurationName
67 = new XmlQualifiedName ("yearMonthDuration", InternalPool.XdtNamespace);
68 internal static readonly XmlSchemaSimpleType XdtYearMonthDuration
69 = XmlSchemaType.GetBuiltInSimpleType (XdtYearMonthDurationName);
71 internal static readonly XmlQualifiedName XsDateTimeName
72 = new XmlQualifiedName ("dateTime", XmlSchema.Namespace);
73 internal static readonly XmlSchemaSimpleType XsDateTime
74 = XmlSchemaType.GetBuiltInSimpleType (XsDateTimeName);
76 internal static readonly XmlQualifiedName XsFloatName
77 = new XmlQualifiedName ("float", XmlSchema.Namespace);
78 internal static readonly XmlSchemaSimpleType XsFloat
79 = XmlSchemaType.GetBuiltInSimpleType (XsFloatName);
80 internal static readonly XmlQualifiedName XsDoubleName
81 = new XmlQualifiedName ("double", XmlSchema.Namespace);
82 internal static readonly XmlSchemaSimpleType XsDouble
83 = XmlSchemaType.GetBuiltInSimpleType (XsDoubleName);
84 internal static readonly XmlQualifiedName XsDecimalName
85 = new XmlQualifiedName ("decimal", XmlSchema.Namespace);
86 internal static readonly XmlSchemaSimpleType XsDecimal
87 = XmlSchemaType.GetBuiltInSimpleType (XsDecimalName);
88 internal static readonly XmlQualifiedName XsIntegerName
89 = new XmlQualifiedName ("integer", XmlSchema.Namespace);
90 internal static readonly XmlSchemaSimpleType XsInteger
91 = XmlSchemaType.GetBuiltInSimpleType (XsIntegerName);
93 internal static readonly XmlQualifiedName XsLongName
94 = new XmlQualifiedName ("long", XmlSchema.Namespace);
95 internal static readonly XmlSchemaSimpleType XsLong
96 = XmlSchemaType.GetBuiltInSimpleType (XsLongName);
97 internal static readonly XmlQualifiedName XsIntName
98 = new XmlQualifiedName ("int", XmlSchema.Namespace);
99 internal static readonly XmlSchemaSimpleType XsInt
100 = XmlSchemaType.GetBuiltInSimpleType (XsIntName);
101 internal static readonly XmlQualifiedName XsShortName
102 = new XmlQualifiedName ("short", XmlSchema.Namespace);
103 internal static readonly XmlSchemaSimpleType XsShort
104 = XmlSchemaType.GetBuiltInSimpleType (XsShortName);
105 internal static readonly XmlQualifiedName XsUnsignedLongName
106 = new XmlQualifiedName ("unsignedLong", XmlSchema.Namespace);
107 internal static readonly XmlSchemaSimpleType XsUnsignedLong
108 = XmlSchemaType.GetBuiltInSimpleType (XsUnsignedLongName);
109 internal static readonly XmlQualifiedName XsUnsignedIntName
110 = new XmlQualifiedName ("unsignedInt", XmlSchema.Namespace);
111 internal static readonly XmlSchemaSimpleType XsUnsignedInt
112 = XmlSchemaType.GetBuiltInSimpleType (XsUnsignedIntName);
113 internal static readonly XmlQualifiedName XsUnsignedShortName
114 = new XmlQualifiedName ("unsignedShort", XmlSchema.Namespace);
115 internal static readonly XmlSchemaSimpleType XsUnsignedShort
116 = XmlSchemaType.GetBuiltInSimpleType (XsUnsignedShortName);
118 // Methods
120 public static XmlQualifiedName ParseQName (string name, IXmlNamespaceResolver resolver)
122 int index = name.IndexOf (':');
123 if (index < 0)
124 return new XmlQualifiedName (name);
125 string ns = resolver.LookupNamespace (name.Substring (0, index));
126 if (ns == null)
127 throw new ArgumentException ("Invalid qualified name.");
128 return new XmlQualifiedName (name.Substring (index + 1), ns);
131 public static XmlSchemaType GetBuiltInType (XmlQualifiedName name)
133 XmlSchemaType t = XmlSchemaType.GetBuiltInSimpleType (name);
134 if (t != null)
135 return t;
136 return XmlSchemaType.GetBuiltInComplexType (name);
139 public static XmlSchemaType GetBuiltInType (XmlTypeCode type)
141 XmlSchemaType t = XmlSchemaType.GetBuiltInSimpleType (type);
142 if (t != null)
143 return t;
144 return XmlSchemaType.GetBuiltInComplexType (type);
147 internal static Type RuntimeTypeFromXmlTypeCode (XmlTypeCode typeCode)
149 switch (typeCode) {
150 case XmlTypeCode.Int:
151 return typeof (int);
152 case XmlTypeCode.Decimal:
153 return typeof (decimal);
154 case XmlTypeCode.Double:
155 return typeof (double);
156 case XmlTypeCode.Float:
157 return typeof (float);
158 case XmlTypeCode.Long:
159 return typeof (long);
160 case XmlTypeCode.Short:
161 return typeof (short);
162 case XmlTypeCode.UnsignedShort:
163 return typeof (ushort);
164 case XmlTypeCode.UnsignedInt:
165 return typeof (uint);
166 case XmlTypeCode.String:
167 return typeof (string);
168 case XmlTypeCode.DateTime:
169 return typeof (DateTime);
170 case XmlTypeCode.Boolean:
171 return typeof (bool);
172 case XmlTypeCode.Item:
173 return typeof (object);
175 throw new NotSupportedException (String.Format ("XQuery internal error: Cannot infer Runtime Type from XmlTypeCode {0}.", typeCode));
178 internal static XmlTypeCode XmlTypeCodeFromRuntimeType (Type cliType, bool raiseError)
180 switch (Type.GetTypeCode (cliType)) {
181 case TypeCode.Int32:
182 return XmlTypeCode.Int;
183 case TypeCode.Decimal:
184 return XmlTypeCode.Decimal;
185 case TypeCode.Double:
186 return XmlTypeCode.Double;
187 case TypeCode.Single:
188 return XmlTypeCode.Float;
189 case TypeCode.Int64:
190 return XmlTypeCode.Long;
191 case TypeCode.Int16:
192 return XmlTypeCode.Short;
193 case TypeCode.UInt16:
194 return XmlTypeCode.UnsignedShort;
195 case TypeCode.UInt32:
196 return XmlTypeCode.UnsignedInt;
197 case TypeCode.String:
198 return XmlTypeCode.String;
199 case TypeCode.DateTime:
200 return XmlTypeCode.DateTime;
201 case TypeCode.Boolean:
202 return XmlTypeCode.Boolean;
203 case TypeCode.Object:
204 return XmlTypeCode.Item;
206 if (raiseError)
207 throw new NotSupportedException (String.Format ("XQuery internal error: Cannot infer XmlTypeCode from Runtime Type {0}", cliType));
208 else
209 return XmlTypeCode.None;
215 #endif