Static Public Member Functions | |
DOMParser | newParser (boolean validate) |
Allocate and initialize a new DOM parser. | |
Static Package Attributes | |
final String | NAMESPACES_FEATURE_PREFIX = "http://xml.org/sax/features/namespaces" |
the namespace feature is true by default | |
final String | VALIDATION_FEATURE = "http://xml.org/sax/features/validation" |
final String | VALIDATION_SCHEMA_FEATURE = "http://apache.org/xml/features/validation/schema" |
Static Private Member Functions | |
void | setFeature (DOMParser parser, String featureURI, String featureName) |
Set a feature in the parser and report any errors. | |
void | initParser (DOMParser parser, boolean validate) |
Turn on validation in the parser object. |
|
Turn on validation in the parser object. The W3C (www.w3.org) and Apache (www.apache.org) documentation is less than clear when it comes to XML Schemas and XML parsers. Initializing a parser so that it performs validation is rather obscure. The features that are set in initialization are URI strings. These are defined on the Apache web page: http://xml.apache.org/xerces2-j/features.html A parser feature is turned on by calling the parser method setFeature( featureStr, true ), where featureStr is one of the features defined on the Apache web page. The feature to turn on schema validation is: http://apache.org/xml/features/validation/schema Error reporting requries that the basic validation feature be turned on as well. This is: http://xml.org/sax/features/validation Note that one feature uses apache.org and the other uses xml.org. Apparently this is historical: the base validation feature was originally for DTDs. The validation/schema feature is for XML Schema Descriptions (XSDs).
|
|
Allocate and initialize a new DOM parser.
|
|
Set a feature in the parser and report any errors.
|
|
the namespace feature is true by default
|
|
|
|
|