Schema(schema); Document Builder doc Builder = Document Builder(); doc Builder.parse(..
These statements, are all that are necessary to accomplish this task.
But there, are few catches here, which I wish to share.
1) If Validating(true) is specified, then a DTD is mandatory.
Before going into the major points related to XML Schema questions on the exam, let's make sure we understand how to use Java to perform a validity check for an XML document.
Following is a sequence of instructions which needs to be written for this: Document Builder Factory dbf = Document Builder Instance(); Namespace Aware(true); Validating(true); Schema Factory schema Factory = Schema Instance(XMLConstants.
W3C_XML_SCHEMA_NS_URI); Schema schema = schema Schema ...
As with XSLT transformation explained in the previous volume, we can easily perform this check if we use the standard API "JAXP (Java API for XML Processing)" included in J2SE 5.0.
List1 shows an example of a program created in JAXP that performs a validity check.