public abstract class XmlSchemaDatatype
|
using System; using System.Xml; using System.Xml.Schema; class XMLSchemaExamples { public static void Main() { XmlTextReader xtr = new XmlTextReader("example.xsd"); XmlSchema schema = XmlSchema.Read(xtr, new ValidationEventHandler(ValidationCallbackOne)); schema.Compile(new ValidationEventHandler(ValidationCallbackOne)); foreach (XmlSchemaObject schemaObject in schema.Items) { if (schemaObject.GetType() == typeof(XmlSchemaSimpleType)) { XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) schemaObject; Console.WriteLine("{0} {1}", simpleType.Name, simpleType.Datatype.ValueType); } if (schemaObject.GetType() == typeof(XmlSchemaComplexType)) { XmlSchemaComplexType complexType = (XmlSchemaComplexType) schemaObject; Console.WriteLine("{0} {1}", complexType.Name, complexType.Datatype.ValueType); } } xtr.Close(); } public static void ValidationCallbackOne(object sender, ValidationEventArgs args) { Console.WriteLine(args.Message); } }
The following XML file is used for the preceding code example.
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:simpleType name="LotteryNumber"> <xs:restriction base="xs:int"> <xs:minInclusive value="1"/> <xs:maxInclusive value="99"/> </xs:restriction> </xs:simpleType> </xs:schema>
TokenizedType | Read-only Gets the type for the string as specified in the World Wide Web Consortium (W3C) XML 1.0 specification. |
ValueType | Read-only Gets the .NET Framework type for the specified XML Schema definition language (XSD) type. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
ParseValue | Parses values from the XmlNameTable. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
ctor #1 | Default constructor. This constructor is called by derived class constructors to initialize state in this type. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
protected XmlSchemaDatatype(); |
public abstract XmlTokenizedType TokenizedType {get;}
|
The following table shows the token types.
XmlTokenizedType Enum | Description |
---|---|
CDATA | CDATA type |
ID | ID type |
IDREF | IDREF type |
IDREFS | IDREFS type |
ENTITY | ENTITY type |
ENTITIES | ENTITIES type |
NMTOKEN | NMTOKEN type |
NMTOKENS | NMTOKENS type |
NOTATION | NOTATION type |
ENUMERATION | ENUMERATION type |
QName | QName type |
NCName | NCName type |
None | No type |
public abstract Type ValueType {get;}
|
XSD types | .NET Framework Types |
---|---|
hexBinary | System.Byte[] |
base64Binary | System.Byte[] |
Boolean | System.Boolean |
byte | System.SByte |
normalizedString | System.String |
date | System.DateTime |
decimal | System.Decimal |
double | System.Double |
ENTITIES | System.String[] |
ENTITY | System.String |
float | System.Single |
gMonthDay | System.DateTime |
gDay | System.DateTime |
gYear | System.DateTime |
gYearMonth | System.DateTime |
ID | System.String |
IDREF | System.String |
IDREFS | System.String[] |
int | System.Int32 |
integer | System.Decimal |
language | System.String |
long | System.Int64 |
month | System.DateTime |
Name | System.String |
NCName | System.String |
negativeInteger | System.Decimal |
NMTOKEN | System.String |
NMTOKENS | System.String[] |
nonNegativeInteger | System.Decimal |
nonPositiveInteger | System.Decimal |
NOTATION | System.String |
positiveInteger | System.Decimal |
QName | System.Xml.XmlQualifiedName |
short | System.Int16 |
string | System.String |
time | System.DateTime |
timePeriod | System.DateTime |
timePeriod | System.DateTime |
token | System.String |
unsignedByte | System.Byte |
unsignedInt | System.UInt32 |
unsignedLong | System.UInt64 |
unsignedShort | System.UInt16 |
anyURI | System.Uri |
~XmlSchemaDatatype(); |
public virtual int GetHashCode(); |
public Type GetType(); |
protected object MemberwiseClone(); |
public abstract object ParseValue( |
s
nameTable
nsmgr
public virtual string ToString(); |