O'Reilly logo

Java and XML by Brett McLaughlin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Java Parallels

As the XML Schema specification has solidified, the similarity between XML Schema and Java class and interface definitions has only increased. Although still strictly only a set of constraints, an XML Schema closely models the code you write in Java when creating a class or interface definition. The schema defines the set of allowed data that is contained within an XML document; this is similar to the way a Java class or interface defines the allowed methods and variables that an instance of the class may represent. Just as a Java program only needs to know this definition to use the instance (without having to know specific details about the instance implementation, such as its memory address or contents), an XML-aware application only needs to understand a document’s constraints (defined in the XML Schema) to use the XML document.

The importance of this parallel might not seem obvious to you; however, this facet of XML Schema is particularly critical to how XML may be used in new types of applications, and new implementations of old techniques. We look at just a few of these important applications here, but you should be able to extend these concepts to many more uses, perhaps pushing the envelope of your own applications’ functionality.

Equivalence

One important concept that XML Schema introduces is element equivalence. In XML 1.0 and DTDs, one element type must be mapped to one element. In other words, if two elements shared identical content, both elements had ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required