Microsoft HomeproductssearchsupportshopWrite Us   Microsoft Home
Magazine
 |  Community
 |  Workshop
 |  Tools & Samples
 |  Training
 |  Site Info

Workshop  |  XML (Extensible Markup Language)

XML Tutorial
Lesson 6: Using Data Types Within XML Documents


Updated: November 4, 1998

What is a data type within an XML document?

Microsoft is providing this release of XML Schema with data type support, as a technology preview that may be useful for developers interested in building prototypes and gaining experience with schema and rich data types. Microsoft is actively involved in defining the emerging W3C XML schema standard and will track this effort. Developers should note that this version of XML Schema is subject to change.

In Microsoft Internet Explorer 5 Beta, element values can be assigned data types. These data types can be assigned through an XML schema or on the instance.

Previously, XML element values were limited to a single type (String), so developers who wished to process XML documents had to spend time converting all values to a type within their own applications. Typing your XML data will let the parser take care of data type conversions. In addition, because values are assigned a particular data type, changes made to that value will have to conform to that data type. This provides you with a method of validating user input.

How do I type XML element values?

To type an element through an XML Schema, one must declare the data type namespace along with the schema namespace at the beginning of the XML Schema:

<Schema xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes">

The dt prefix can now be used within the schema to denote which type attributes hold data type designations:

<ElementType name="NUMBER" dt:type="number"/>

To type an element through the dt attribute on the instance of the element, one must declare the data type namespace at the beginning of the XML document:

<NUMBERS xmlns:dt="urn:schemas-microsoft-com:datatypes">

The dt prefix can now be used on the dt attribute to assign a data type to an instance of an element:

<NUMBERS xmlns:dt="urn:schemas-microsoft-com:datatypes">
  <NUMBER dt:dt="number">44533</NUMBER>
</NUMBERS>

See Supported Data Types for a list of data types that you can use within your XML documents.

Try it!

Sorry! The interactive exercises require Internet Explorer 5 Beta Non-SBN link.


Did you find this article useful? Gripes? Compliments? Suggestions for other articles? Write us!

Back to topBack to top

© 1998 Microsoft Corporation. All rights reserved. Terms of use.

 

Magazine Home
Ask Jane
DHTML Dude
Extreme XML
For Starters
More or Hess
Servin' It Up
Site Lights
Web Men Talking
Member Community Home
Benefits: Freebies & Discounts
Benefits: Promote Your Site
Benefits: Connect with Your Peers
Benefits at a Glance
Online Special-Interest Groups
Your Membership
SBN Stores
Join Now
Workshop Home
Essentials
Content & Component Delivery
Component Development
Data Access & Databases
Design
DHTML, HTML & CSS
Extensible Markup Language (XML)
Languages & Development Tools
Messaging & Collaboration
Networking, Protocols & Data Formats
Reusing Browser Technology
Security & Cryptography
Server Technologies
Streaming & Interactive Media
Web Content Management
Workshop Index
Tools & Samples Home
Tools
Samples, Headers, Libs
Images
Sounds
Style Sheets
Web Fonts
Training Home
SBN Live Seminars
SBN Live Chats
Courses
Peer Support
CD-ROM Training
Books & Training Kits
Certification
SBN Home
New to SBN?
What's New on SBN
Site Map
Site Search
Glossary
Write Us
About This Site