This section provides a tutorial example on how to use the Xerces2 sample program called dom.Counter to validate XML documents with associated XSD schema files using the '-v -s' options.
To fully testing the XSD schema validation feature of dom.Counter,
I need to create two files: hello.xsd and hello_xsd_invalid.xml:
Surprise, where is the expected schema validation error?
The sub element "i" is not defined in hello.xsd.
Checking the documentation of Xerces2 features again at the
http://xerces.apache.org/xerces2-j/features.html again,
I see that the schema validation feature (-s option) requires
the basic validation feature (-v option) turned on to report errors:
>jdk8x2r dom.Counter -v -s hello_xsd_invalid.xml
[Error] hello_xsd_invalid.xml:4:24: cvc-type.3.1.2: Element 'p' is a
^^^ simple type, so it must have no element information item
^^^ [children].
hello_xsd_invalid.xml: 273;8;0 ms (2 elems, 2 attrs, 0 spaces,
^^^ 13 chars)
Very good. dom.Counter does support XSD schema validation
and report back errors, if you use "-v -s" options.