Search /
Docfinder:
Advanced search  |  Help  |  Site map
RESEARCH CENTERS
SITE RESOURCES
Click for Layer 8! No, really, click NOW!
Networking for Small Business
TODAY'S NEWS
iPhone 5 rumor rollup for the week ending Feb. 10
Forget Public Cloud or Private Cloud, It's All About Hyper-Hybrid
Apple passes HP as largest tech company
How to get the IRS' attention: Forge nearly $8 million in tax returns, steal identities
Much of Western U.S. is a 3G wasteland, says FCC
How the Phoenix Suns basketball team takes on social media attacks
Microsoft details Windows 8 for ARM devices
Resume Makeover: How an Information Security Professional Can Target CSO Jobs
Blogger exposes major Google Wallet security flaw
Web app lets enterprise set security, sharing for Google Apps users
Cloudscaling to offer OpenStack private cloud platform
Macs take on the enterprise
Valentine's Day Patch Tuesday: Microsoft to issue 9 patches, 4 critical
Mobile World Congress sneak peek: Quad-core smartphones, Ice Cream Sandwich & more
/

XSD gets even more interesting

Related linksToday's breaking news
Send to a friendFeedback

Gearhead archive

First, a correction regarding last week's column on XML Schema Definition. In the part about creating derived data types, we goofed. Eagle-eyed reader Will Wagers wrote to tell us of our error: "Surely, you meant -2 to the 63 to 2 to the 63 -1?"Surely we did. The moral is never edit by cell phone while driving at, ahem, 65 mph.

This week we promised XSD would get interesting when what we meant was "even more interesting" . . . .

So by now you should have a pretty good idea of XSD's primitive (also called "basic") and derived data types. Just to make things even more gripping, that's not all! Oh no, XSD also has complex types that are derived from multiples and/or combinations of primitive and derived types.

This example is borrowed from a book we highly recommend: Architecting Web Services by William Oellermann Jr. Oellermann covers a huge amount of ground in this book in as easily understood a manner as possible considering the inherent complexity of the subject.

While we're at it, we should mention another book that we rather like that attempts to ease you into the dark recesses of XSD and, indeed, many other things XML-related - XML for the World Wide Web by Elizabeth Castro.

Castro's book is not quite as detailed (or as long) as Oellermann's but has more examples that are more detailed, making it easier to understand the principles of XML, XSD and related technologies. We recommend getting both books.

So here's a complex type defined:

<complexType name = "money" >
<simpleContent>
<extension base = "decimal">
<attribute name = "currency" type = "string" />
</extension>
</simpleContent>
</complexType>

The complex type that we're defining is called "money," and it is based on the primitive type "decimal." But we need to add to the type an attribute that defines the currency - hence the "extension" element.

This XSD specification applied to the following XML would pass validation:

<money currency="USD">123.45</money>

So far all we've done is just lightly scratch the surface of creating a schema using XSD, but you can see how definitions under XSD create templates for validating XML content.

We recommend that you check out the World Wide Web Consortium's XSD primer, but you might want to read either or both of our recommended books first - the W3C stuff is beyond exhaustive.

A helping hand

As you can imagine, creating an XSD by hand would be very time-consuming and error-prone, but, fear not, there are tools to help you create and validate XML content against XSD specifications.

One of the most highly rated XML tool suites is XML Spy from Altova (www.xmlspy.com). XML Spy is for creating and validating XML schemas, Document Type Definitions (DTD) and documents. It presents you with an integrated development environment with multiple panes and automatically generates code in the background. You can validate XML, DTD and XSD documents using the built-in incremental parser.

Most of the process of constructing something like an XML or XSD document is a matter of drag-and-drop and, where required, XML Spy can generate an Access database to support an XML document.

This is an awesome tool, but don't underestimate the steep learning curve that comes with such sophistication. Then again, XML and XSD aren't for techno-wimps anyway.

Another major player in this market is SoftQuad (recently swallowed up by Corel) with the XMetal product (http://shorterlink.com/?XZCU9Y).

XMetal was one of the earliest and most polished XML editing tools and the latest release, Version 3.0, includes XSD support. We have yet to get our hands on this product but it looks very promising (see http://shorterlink.com/?ASY1N7 for a full feature list).

Be all that as it may, next week we'll carry on with our tour through Web services technology.

So what are you doing with Web services? Spill your content to gearhead@gibbs.com.

RELATED LINKS


NWFusion offers more than 40 FREE technology-specific email newsletters in key network technology areas such as NSM, VPNs, Convergence, Security and more.
Click here to sign up!
New Event - WANs: Optimizing Your Network Now.
Hear from the experts about the innovations that are already starting to shake up the WAN world. Free Network World Technology Tour and Expo in Dallas, San Francisco, Washington DC, and New York.
Attend FREE
Your FREE Network World subscription will also include breaking news and information on wireless, storage, infrastructure, carriers and SPs, enterprise applications, videoconferencing, plus product reviews, technology insiders, management surveys and technology updates - GET IT NOW.