Designing Your own XML Schema: Learn the Essentials (Page 1 of 6 )
What is XML Schema and why does it exist?
XML documents (or files with the extension “.xml”) are designed with no rules and regulations by default. Don’t be misled by the phrase “no rules and regulations.” In this sense, I mean that it is “highly customizable.” That means no one in this world can constrain or stop you from defining your own “markup” language. You can start with your own elements, attributes, and values along with your own structure.
But any “customized markup” should have a particular structure, which should be easily understood by existing platforms. If you design your own markup and hand it to another person to extend it, the next person should conform to all of your “rules and regulations” in extending your markup. This is simply not possible with oral communications.
There needs to be some type of language, which should express “all of your rules and regulations” for defining and using your own markup. The language needs to describe or express the structure of your markup and several other constrainable features being used in your XML document, like data types, nesting, repetition, and so on. In the past, to deal with all of these issues, we had DTD (Document Type Definition). And now, we have “XML Schema” (which itself is defined in the form of an XML document).
XML Schema is a language for describing the structure and constraining the contents of XML documents. A schema guarantees that the XML elements linked to it follow the defined structure. It is always suggested (or strongly recommended) to design and work with XML Schema, before starting to work with XML documents straight away, so that the XML documents would be easily validated.
To validate an XML document against XML Schema, we need to have certain XML parsers or engines to start with. Most of the parsers are generally written in Java, and several of them are free to use. MSXML is the XML parser from Microsoft, which is also free. MSXML is automatically installed if you have Internet Explorer 5.5 or above.
If you wanted to design your XML (or schema) with intelli-sense and several other features (such as XSL, XPath, XQuery, and so on), there are beautiful and productive tools such as “XMLSpy” (http://www.xmlspy.com/) and “StylusStudio” (http://www.stylusstudio.com/). But you need to buy them :(
For this series of these articles, I used the xml-processing tool “AltovaXML” (also from the “XMLSpy” guys) which is freely downloadable at http://www.altova.com/altovaxml.html. Even though it is not a GUI based tool, we can operate it from a command line or integrate it with our own Java application, or even integrate it with a .NET application as well. It is really one of my favorites.