Hitachi

uCosminexus Application Server XML Processor User Guide


4.4.1 How to Set the XML Schema Properties for the DOM Parser

To set any XML Schema properties to the DOM parser, use the setAttribute method of the javax.xml.parsers.DocumentBuilderFactory class. How to set a property is shown below.

[Figure]

The following describes the coding example. Each item number corresponds to the number in the comments in the coding example.

  1. Perform the setting that enables validation.

    Set the argument of the setValidating method on the javax.xml.parsers.DocumentBuilderFactory class to true. This setting enables the XML document validation function.

  2. Set the schema language to use for schema validation.

    Using the setAttribute method of the javax.xml.parsers.DocumentBuilderFactory class, for the property string "http://java.sun.com/xml/jaxp/properties/schemaLanguage" set the value "http://www.w3.org/2001/XMLSchema", which indicates that validation will follow the XML Schema specification.

  3. Identify the schema document.

    Using the setAttribute method of the javax.xml.parsers.DocumentBuilderFactory class, for the property string "http://java.sun.com/xml/jaxp/properties/schemaSource" specify the schema document used for validation. This specification is not necessary if the schema document is identified in the XML document.