This is useful for adding constraints that are more easily checked in a Turing-complete language like Java than in a declarative language like the W3C XML Schema language.
(This description is painted with broad strokes -- there are exceptions.)Until recently, the exact Application Programming Interface (API) by which programs requested validation varied with the schema language and parser.DTDs and XSD were normally accessed as configuration options in Simple API for XML (SAX), Document Object Model (DOM), and Java™ API for XML Processing (JAXP). Schematron might use the Transformations API for XML(Tr AX); and still other schema languages required programmers to learn still more APIs, even though they were performing essentially the same operation.Java 5 introduced the package to provide a schema-language-independent interface to validation services.The Java language doesn't tell you what it means or convert the data to a Java type such as can call at any time to find out the type of the current element or one of its attributes.It can also tell you whether an attribute is an ID, and whether the attribute was explicitly specified in the document or defaulted in from the schema. book: #Anon Type_book title: #Anon Type_title subtitle: #Anon Type_subtitle info: #Anon Type_info copyright: #Anon Type_copyright year: #Anon Type_year holder: #Anon Type_holder author: #Anon Type_author personname: #Anon Type_personname firstname: #Anon Type_firstname othername: #Anon Type_othername surname: #Anon Type_surname personblurb: #Anon Type_personblurb para: #Anon Type_para link: #Anon Type_link As you can see, the Doc Book schema assigns most elements anonymous complex types.
You can also tell whether and how a type is derived from another type.