System.Xml.Schema.XmlSchemaDatatype Class

Assembly: System.Xml.dll
Namespace: System.Xml.Schema
Summary
Represents the abstract class for mapping XML Schema definition language (XSD) and .NET Framework types.
C# Syntax:
public abstract class XmlSchemaDatatype
Example
The following example shows use of the XmlSchemaDatatype class.
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>

    
See also:
System.Xml.Schema Namespace

System.Xml.Schema.XmlSchemaDatatype Member List:

Public Properties
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.
Public Methods
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.
Protected Constructors
ctor #1 Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Protected Methods
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:


System.Xml.Schema.XmlSchemaDatatype Member Details

ctor #1
Summary:
Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
protected XmlSchemaDatatype();

Return to top


Property: TokenizedType (read-only)
Summary
Gets the type for the string as specified in the World Wide Web Consortium (W3C) XML 1.0 specification.
C# Syntax:
public abstract XmlTokenizedType TokenizedType {get;}
Remarks
Allows the string to be read as a particular XML type, for example, a CDATA section type.

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

Return to top


Property: ValueType (read-only)
Summary
Gets the .NET Framework type for the specified XML Schema definition language (XSD) type.
C# Syntax:
public abstract Type ValueType {get;}
Remarks
The table maps the XML Schema and .NET Framework types.

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

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~XmlSchemaDatatype();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ParseValue(
   string s,
   XmlNameTable nameTable,
   XmlNamespaceManager nsmgr
)
Summary
Parses values from the XmlNameTable.
C# Syntax:
public abstract object ParseValue(
   string s,
   XmlNameTable nameTable,
   XmlNamespaceManager nsmgr
);
Parameters:

s

string

nameTable

XmlNameTable

nsmgr

XmlNamespaceManager

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.