This page documents the various Java API for XML Processing (JAXP) samples included with Xerces. Besides being useful programs, they can be used as JAXP programming examples to learn how to program using the JAXP API.
JAXP samples:
A sample which demonstrates usage of classes in the javax.xml.parsers package, particularly new features introduced in JAXP 1.3 and 1.4, including XInclude processing, integration with the JAXP 1.4 Validation API and parser reset.
| Option | Description |
|---|---|
| -a uri ... | Provide a list of schema documents. |
| -api (sax|dom) | Select API to use (sax|dom). |
| -xi | -XI | Turn on/off XInclude processing. |
| -sp | -SP | Turn on/off secure processing. |
| -h | Display help screen. |
A sample demonstrating how to use the JAXP 1.4 Validation API to create a validator and use the validator to validate input from SAX, DOM or a stream. The output of this program shows the time spent executing the Validator.validate(Source) method.
This class is useful as a "poor-man's" performance tester to compare the speed of various JAXP 1.4 validators with different input sources. However, it is important to note that the first validation time of a validator will include both VM class load time and validator initialization that would not be present in subsequent validations with the same document. Also note that when the source for validation is SAX or a stream, the validation time will also include the time to parse the document, whereas the DOM validation is completely in memory.
| Option | Description |
|---|---|
| -l name | Select schema language by name. |
| -x number | Select number of repetitions. |
| -a uri ... | Provide a list of schema documents. |
| -i uri ... | Provide a list of instance documents to validate. |
| -vs source | Select validation source (sax|dom|stax|stream). |
| -f | -F |
Turn on/off Schema full checking. NOTE: Not supported by all schema factories and validators. |
| -hs | -HS |
Turn on/off honouring of all schema locations. NOTE: Not supported by all schema factories and validators. |
| -va | -VA |
Turn on/off validation of schema annotations. NOTE: Not supported by all schema factories and validators. |
| -ga | -GA |
Turn on/off generation of synthetic schema annotations. NOTE: Not supported by all schema factories and validators. |
| -m | -M | Turn on/off memory usage report. |
| -h | Display help screen. |
The speed and memory results from this program should NOT be used as the basis of parser performance comparison! Real analytical methods should be used. For better results, perform multiple validations within the same virtual machine to remove class loading from parse time and memory usage.
Not all features are supported by different parsers.
A sample demonstrating how to use the JAXP 1.4 Validation API to create a validator and use the validator to validate input from a DOM which contains inline schemas and multiple validation roots. The output of this program shows the time spent executing the Validator.validate(Source) method.
This class is useful as a "poor-man's" performance tester to compare the speed of various JAXP 1.4 validators with different input sources. However, it is important to note that the first validation time of a validator will include both VM class load time and validator initialization that would not be present in subsequent validations with the same document.
| Option | Description |
|---|---|
| -l name | Select schema language by name. |
| -x number | Select number of repetitions. |
| -a xpath ... | Provide a list of XPath expressions for schema roots. |
| -i xpath ... | Provide a list of XPath expressions for validation roots. |
| -nm pre uri ... | Provide a list of prefix to namespace URI mappings for the XPath expressions. |
| -f | -F |
Turn on/off Schema full checking. NOTE: Not supported by all schema factories and validators. |
| -hs | -HS |
Turn on/off honouring of all schema locations. NOTE: Not supported by all schema factories and validators. |
| -va | -VA |
Turn on/off validation of schema annotations. NOTE: Not supported by all schema factories and validators. |
| -ga | -GA |
Turn on/off generation of synthetic schema annotations. NOTE: Not supported by all schema factories and validators. |
| -m | -M | Turn on/off memory usage report. |
| -h | Display help screen. |
The speed and memory results from this program should NOT be used as the basis of parser performance comparison! Real analytical methods should be used. For better results, perform multiple validations within the same virtual machine to remove class loading from parse time and memory usage.
Not all features are supported by different parsers.
Provides a trace of the schema type information for elements and attributes in an XML document. This demonstrates usage of the JAXP 1.4 Validation API, particuarly how to read type information from a TypeInfoProvider.
| Option | Description |
|---|---|
| -l name | Select schema language by name. |
| -p name | Select parser by name. |
| -a uri ... | Provide a list of schema documents. |
| -i uri ... | Provide a list of instance documents to validate. |
| -f | -F |
Turn on/off Schema full checking. NOTE: Not supported by all schema factories and validators. |
| -hs | -HS |
Turn on/off honouring of all schema locations. NOTE: Not supported by all schema factories and validators. |
| -va | -VA |
Turn on/off validation of schema annotations. NOTE: Not supported by all schema factories and validators. |
| -ga | -GA |
Turn on/off generation of synthetic schema annotations. NOTE: Not supported by all schema factories and validators. |
| -h | Display help screen. |
A sample which demonstrates usage of the JAXP 1.3 Datatype API.