SQL Server MVP Jacob Sebastian's new e-book, The Art of XSD, is available as a free download from Red Gate software at http://www.red-gate.com/specials/Ebooks/XSD_0409.htm. You may reognize Jacob from his many XML-related articles on SQL Server Central (http://www.sqlservercentral.com/Authors/Articles/Jacob_Sebastian/212008/). This book allows him to focus on the core functionality of XML Schema collections, which are key to validating your XML data in SQL Server.
Way back in the day, when XML was first introduced, there was no standard or automated mechanism to type or constrain your XML data. If you wanted to make sure that an <Age> element contained only numeric values between 1 and 100, for instance, you had to write one-off programs and additional code to perform this check for you in a procedural language. If you wanted to ensure that a <PhoneNumber> element always matched the pattern xxx-xxx-xxxx, you had to again write custom code to accomplish this.
XML Schema collections provide the mechanism for automated validation of XML documents. An XML Schema collection is a collection of XML Schema documents (XSDs), that allow you to constrain the format and content of your XML. If you process and store XML data (or if you will at some point in the future) you'll undoubtedly encounter a need to ensure consistency of your XML data. In The Art of XSD Jacob describes in detail how to use XML Schema collections to add constraints to your XML data. Here is a small sampling of the many tasks that Jacob expertly guides you through in this book:
- How to ensure that your XML documents follow a specified structure
- How to make some elements mandatory and others optional
- How to enforce an exact specified order for elements
- How to ensure that numeric values in your XML fall within a given range or belongs to a set of values
- How to validate character data in your XML matches a regular expression pattern
- How to use XML namespaces to constrain content
- ...and a whole lot more
Jacob walks you through the process of creating your own XML Schema collections, step-by-step, on an expertly guided tour. If you currently process and store XML data, or if you think you might in the future, get this book! It's well-written and the author is a true subject matter expert. Right now they're giving this book away for free--hurry up and download your copy before these guys change their minds!
You can get your copy of Jacob's book at http://www.red-gate.com/specials/Ebooks/XSD_0409.htm.
UPDATE: Got an XML Schema question or want to discuss the book's content? Jacob has started a new forum off his main blog to discuss The Art of XSD and XML Schema-specific topics @ http://beyondrelational.com/groups/the_art_of_xsd/default.aspx.