Schema validation with XSDValidator
In this section, we shall create a schema validation application using the schema validator class oracle.xml.schemavalidator.XSDValidator
. The application is created in the XMLSchemaValidator
class. Import the oracle.xml.parser.schema
package and the oracle.xml.schemavalidator.XSDValidator
class.
Creating a schema validator
The XSDValidator
class is used to validate an XML document that has been built into a DOM tree. First, we need to create an XSDValidator
object:
XSDValidator xsdValidator = new XSDValidator ();
The XML schema with which an XML document is validated is set with the setSchema(XMLSchema)
method. An XMLSchema
object represents a schema document as a DOM tree. An XSDBuilder
object is used to create an XMLSchema
object from an XML schema document. Create an XSDBuilder
object:
XSDBuilder builder = new XSDBuilder();
Build an XMLSchema
object from an InputSource
object using the build(InputSource)
method. The XSDBuilder
class provides the overloaded...