Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News

SYS-CON.TV
Cloud Expo & Virtualization 2009 East
PLATINUM SPONSORS:
IBM
Smarter Business Solutions Through Dynamic Infrastructure
IBM
Smarter Insights: How the CIO Becomes a Hero Again
Microsoft
Windows Azure
GOLD SPONSORS:
Appsense
Why VDI?
CA
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
ExactTarget
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun
Sun's Incubation Platform: Helping Startups Serve the Enterprise
POWER PANELS:
Cloud Computing & Enterprise IT: Cost & Operational Benefits
How and Why is a Flexible IT Infrastructure the Key To the Future?
Click For 2008 West
Event Webcasts
XML Schemas In Action
XML Schemas In Action

XML Schemas have truly entered the picture with the Internet standards organization, W3C, advancing it to Candidate Recommendation status in late October 2000. You may ask, Who cares? Well, developers with any interest in XML. This means XML Schemas are here to stay, so start learning the ins and outs of them.

A great aspect of the XML Schema specification is the syntax. It utilizes standard XML, so all XML knowledge is transferable. The days of learning the grimy details of document type definitions (DTDs) are ending. The major drawback of a DTD is its arcane syntax, which is derived from Standard Generalized Markup Language (SGML). SGML was a precursor to XML, so it makes sense that DTDs were quickly adopted. Problems arose when XML-savvy individuals experienced the DTD syntax. I won't delve into DTD basics; rather I'll discuss a recent opportunity I had to put the XML Schema standard to work.

The Data
This project required the retrieval of commodity data from the Chicago Board of Trade (CBOT). The data is available through a variety of services from non-CBOT companies, so you must deal with a middleman to get it. After an extensive search a Chicago-based vendor, FutureSource, was selected. The main reason they were selected was the fact that they supported XML. Their data is available via an XML stream using a standard Web (HTTP) request.

The basic flow of information is as follows: the request is sent to the FutureSource server via a Web address (URL) with a variable number of parameters, and an XML document is returned. One odd occurrence with the company is that they didn't utilize any DTD (or Schema). The explanation conveyed by their sales staff was that their data is always consistent. They control it, so there's no need to check its validity.

My clients disagreed with this explanation, and I can't say I blame them. They requested the creation of accompanying Schema for the XML data. The main reason was that the data will be massaged and used throughout the organization, so it's better to get a handle on expectations now rather than later. One major drawback was the vendor's control of the XML. They can change the data structure at any time. Any change has an immediate impact on our design, but the client was not fazed. Consequently, we moved forward with the project by selecting a standard set of tools.

The Technology
The following list shows the technologies used:

  • Java JDK 1.2
  • Xerces XML parser 1.3
  • Xalan XML processor 2.0
  • Text editor for editing various files
Xerces 1.3 was chosen due to its support for the XML Schema standard with no code modifications. That is, parsing is handled the same whether a DTD, an XML Schema, or nothing is utilized. The XML Schema or DTD is specified in the XML document. Now we examine the contents of the XML received (expected) via an HTTP request.

The XML
The XML returned for one commodity is included in Listing 1. This is a standard set of data that's expected, so the data must always be formatted as such.

Explanation of Listing 1

  1. The root element of the XML document is opened.
  2. The target XML namespace is declared. This points to the XML Schema declaration on the W3C site. This must be included in the root element.
  3. The xsi attribute is used to specify the location of the XML Schema file. This points to a schema in the same directory as the XML file. This must be included in the root element.
  4. The quote element is declared with its opening tag and contains three attributes.
  5. The type element in the quote element is defined.
  6. The root element is closed.

XML isn't complicated, but the elements within a quote element must arrive in the same order along with other requirements. We'll now discuss the XML Schema developed for our XML.

The XML Schema
The development of a Schema wasn't complicated, but it was a challenge (i.e., a learning curve) as it was an introduction to the technology. Actually, it was an indoctrination. Listing 2 showcases the Schema developed.

Explanation of Listing 2

  1. XML document is declared.
  2. The XML Schema namespace is designated.
  3. The root element quotes are defined.
  4. The quote element is complex considering it contains elements as well as attributes. The opposite is simpleType.
  5. The quote element is established and may occur zero or more times.
  6. The quote element is complex as well.
  7. The elements of the quote element must appear in the designated order; the sequence directive signals this.
  8. The elements contained within the quote element are defined. The type element contains string data.
  9. The attribute status of the quote ele- ment is defined and is required.
  10. The attribute request of the quote element is defined and is required.
  11. The quote element's closing tag.
  12. The request attribute of the quotes element is defined and is required.
The one great aspect of the XML Schema in Listing 2 is that it's XML. The Schema conforms to XML construction rules just like any other XML document. The document must be well formed with all elements possessing opening and closing elements. The other advantage is that it was completely unnecessary to learn a new standard such as DTDs. I was familiar with XML, so it made the learning process much more friendly and straightforward.

Examine the DTD snippet in Listing 3 if you don't believe this was a problem. It contains a portion of a DTD developed for our XML. Compare it with the XML Schema and you'll see the sheer elegance of the XML Schema specification.

Only the Beginning
The XML Schema specification was only a portion of the project, so the complexity isn't fully demonstrated in this article. The main point is XML Schema's ease of use. In addition, it allows the structure of an XML document to be standardized. The power of XML Schemas extends beyond the scope of this article. The type and format of an element's data can be specified and much more can be discussed. I suggest a thorough perusal of the XML Schema documentation on the W3C Web site.

Resources

  1. Chicago Board of Trade: www.cbot.com
  2. DTD: www.oasis-open.org/docbook/
  3. FutureSource: www.futuresource.com
  4. SGML: www.oasis-open.org/cover/sgml-xml.html
  5. Sun JDK: java.sun.com
  6. Xerces: xml.apache.org
  7. Xalan xml.apache.org
  8. XML Schema spec: www.w3.org/XML/Schema
  9. W3C: www.w3c.org
About Tony Patton
Tony Patton works with various technologies such as Java, XML, HTML,
and Domino. He's the author of Practical LotusScript and Domino
Development With Java, both available from Manning Publications.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Latest Cloud Developer Stories
Swisscom, the Swiss telecom, is going into the cloud business. Its subsidiary Swisscom IT Services AG has signed up with Red Hat as a Certified Cloud Provider and launched a public cloud Infrastructure-as-a-Service (IaaS) cloud targeting enterprise-class customers primarily in ...
Apache Deltacloud, the Red Hat-contributed ReSTful API that abstracts differences between clouds so services on any cloud can be managed – provided of course there’s a driver – has graduated from the Apache Foundation’s incubator and is now a full-fledged Top-Level Project (TLP)....
In a surprise move on Tuesday, January 10, Oracle wheeled out its Big Data Appliance. That’s the one it said in October would be ready sometime in the first half. Only nobody believed it meant early in the first half. Heck, it’s not even clear anybody thought Oracle could make ...
Rackspace Hosting, the service leader in cloud computing, on Thursday announced its acquisition of SharePoint911, an industry leader in SharePoint consulting, training, and "JumpStart" services within SharePoint. The unification of both companies provides capabilities to deliver ...
CloudLinux, Inc., on Thursday released CafeFS 3, a virtualized file system for shared hosters that cages each customer within its own virtualized file system. CageFS becomes part of CloudLinux OS at no additional charge. CloudLinux OS, the only commercially-supported Linux OS m...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON Featured Whitepapers
ADS BY GOOGLE

Breaking Cloud Computing News
As client demand for engagements increases, Revel Consulting (www.revelconsulting.com), a Kirkland, ...