Why You Should Care About XML Schemas
XML schemas should not be confused with XML. Schemas allow you to set rules that apply to XML documents. Rules are good; especially, for XML documents. Schemas define the structure of an XML document. Rules also assist novice XML authors from making mistakes when adding content to an XML document because rules govern what goes in an XML document, and what should be excluded.
Developers often create schemas with optional XML elements. Which begs the question: Are you authoring the schema to determine its structure, or are you authoring a schema to define the rules for content added to an XML document?
If you are creating a schema to define an XML document structure, don’t.
Often XML schemas are reversed engineered from XML documents⎯NOT the correct way to author schemas. One should design a schema. In designing, we must think about what elements are needed in an XML document. Considerations include how to structure the document, what rules to place on the data, and if only certain information should be allowed in the XML document. The proper way to approach schema design does not include reverse engineering an XML concept document to reduce typing.
Sorry, creating a schema is a dirty job. However, the rewards are bountiful when designed appropriately. Appropriately designed schemas produce consistent XML documents, consistent content, reusable content, and structure content.