XML Schema Definition (XSD), also referred to simply as XML Schema, is a schema language used to describe the structure of an XML document. XML Schema was introduced in February of 2000, and version 1 became an official recommendation of the W3C in May of 2001.
XML Schema is based on XML, and as such, it uses the same syntax as XML. This makes it easier to work with, as those creating schemas in XSD are likely already familiar with XML syntax. This also makes it easier to understand the contents of an XML Schema document at a quick glance, as XML aims to be both human- and machine-readable.
With XML Schema, you also have the ability to be specific about the contents of elements and attributes with datatypes. There are many different datatypes available in XML Schema, allowing for more flexibility when describing the content of elements and attributes. Certain datatypes also ensure that proper formatting is followed when adding information to an element. For example, if an element or attribute uses the date data type, if the date isn’t formatted properly, the document won’t validate.
Creating an XML Schema Document
XSD documents can be made in either a text editor, code editor, or XML editor. Let’s go ahead and create a new document in our program of choice, then save it as jobs.xsd. We’ll later use this file to validate job-postings.xml.
NOTE: The following instructions were written using Notepad++. If you're using a different code editor, the steps may be slightly different than what's written here.