My previous post on JSON schema included a slight dig at XML, which perhaps wasn't really warranted. True, XML is clunkier and more verbose than JSON, but it has its strong points. The clincher for me in past projects has been the superior expressiveness of XML's schema format: XSD. XSD has quite a few capabilities that JSON schema lacks, such as referential integrity constraints, and the ability to specify attribute defaults in one's content model. This article provides a quick overview of the latter feature via a code sample that illustrates how to configure Apache Xerces. The configuration we present enables you to read in XML content such that it is auto-populated with the proper default values for attributes, even if the original source XML does not contain any definition at all for those attributes.
Why is this useful? Well, suppose you have developed a content model that allows your users to configure some run time data. For example, say you have a game with actors that can be animals or people. You define an XSD (schema) which allows game configurers to define a cast of characters for the game using XML, like this: