Data points: modeling relational data in XML, part 2
When creating your XML Schema from relational data, each column that contains information you want to model in your schema must have a corresponding data point declaration. There are two ways of doing this.

by Kevin Williams, founder and CEO, Blue Oxide Technologies. Intel Corp.

In the first article in this series, we took a look at the element vs. attribute question for data points and concluded that, for data documents, it makes more sense to model the information as attributes when possible. In this, the second part of our four-part series, we take a look at the issues involved when mapping relational data points (columns) to their XML Schema equivalents.

In this and following articles, we assume that the xsd namespace is mapped to the namespace for XML Schemas v. 1.0: http://www.w3.org/2001/XMLSchema.

Representing data points in XML Schemas
When creating your XML Schema from relational data, each column that contains information you want to model in your schema must have a corresponding data point declaration. As we saw in the first article, there are two ways of doing this: we can model the data point as an element or as an attribute. Let's take a look at how this is done.

Modeling data points as elements
A data point is modeled in an XML Schema using the <xsd:element> element. This element is used to model both elements that contain simple values (data points) and elements that contain further structure—another reason to consider using attributes instead of elements for this purpose. There are a couple of ways you can approach the modeling of the data point: you can either define a global element and then reference it inside your container element using the ref attribute, or you can model the element in place using the name and type attributes. Let's take a look at each mechanism.

Using the name and type attributes
When you model your data points this way, you declare your data point element with the name attribute set to the name of the element containing the datapoint, and the type attribute set to the type of the value contained in the element. This element is then declared in the context of a complexType, either a named complexType or an anonymous complexType declared as part of an element declaration. (Don't worry too much about this distinction right now—we'll learn more about this in the next article). For example, let's say we have a table called Customer we want to model in an XML Schema. The SQL for the table looks something like this:


    CREATE TABLE Customer (


     customerID int,


     customerName varchar(200)


     )

To model the customerName point in our XML Schema using name and type, we would use the following sample element declaration:


<xsd:schema

    xmlns:xsd="http://www.w3.org/2001/XMLSchema">


     <xsd:element name="customer">


     <xsd:complexType>


     <xsd:sequence>


     <xsd:element name="customerName" type="xsd:string"

    />


     </xsd:sequence>


     </xsd:complexType>


     </xsd:element>


    </xsd:schema>

Subscribers who liked this article also read:
Modernizing Cobol for the adaptive enterprise
from Hewlett-Packard LP and Intel Corp. For independent software ve...
Multithreaded technology and multi-core processors
by Craig Szydlowski, Infrastructure Processor Division, Intel Corp. ...

If you're interested in this topic, these articles may be helpful:

Relationships: modeling relational data in XML, part 3
by Kevin Williams, founder and CEO, Blue Oxide Technologies. In thi...
Core Foundation XML parser
from Apple Inc. Core Foundation provides a nonvalidating parser t...
Source code for 'XML security layers, part 2: core technologies—XML encryption and XML signature'
by Manish Verma, principal architect, Second Foundation. First publ...
XMLSpy Home Edition 2005
from Altova Altova XMLSpy 2005 Home Edition is a free entry level X...
XmlPad 2.2. free download
from WMHelp.com XMLPad is based on the unique custom-developed XML ...

Related Jobs:

Software Developer #BK-DEV - PA - Philadelphia - SunGard
Reference No.: BK-DEV Opening Date: July 17, 2007 Job Title: Softw...
Software Development Engineer - Web Applications #26ADD61C339077DF - CA - Oakland - Ask Jeeves,Inc.
Title Software Development Engineer - Web Applications City Oakland ...
Technical Yahoo #RX1000023474 - CA - Sunnyvale - Yahoo! Inc.
Technical Yahoo Job No. RX1000023474 Location US - Sunnyvale ...
Sr. C# .Net OO Developer #3741826 - TX - Houstan - Ajilon
Description : If you're a professional looking for exciting, new oppo...
Senior Web Applications Engineer #C8469CF29B4A750B - CA - Oakland - Ask Jeeves,Inc.
Title Senior Web Applications Engineer City Oakland State CA Zip...
Data Migration Specialist #TEC00001143 - PA - Horsham - The Thomson Corporation
Data Migration Specialist – TEC00001143 Job Description ...
Web Developer/Front End #RX1000022062 - CA - Sunnyvale - Yahoo! Inc.
Web Developer/Front End, Structured Web Search Job No. RX10000...
Web Developer/Front End #RX1000020442 - CA - Sunnyvale - Yahoo! Inc.
Web Developer/Front End - Structured Web Search Job No. RX1000020...
Member of Technical Staff #05YZhAAM - CA - San Francisco - Salesforce.com, Inc.
Member of Technical Staff Location(s): San Francisco, CA - HQ Appl...
.Net Developer #427842 - VA - Arlington - McDonald Bradley, Inc.
427842 - .Net Developer Jul 27, 2007 Arlington, Virginia Send ...