Woodstox : Configuring Woodstox For High Speed

Overview Woodstox provides various configuration options for efficient performance based on environment constraints. In this article, we shall see how to configure Woodstox for speed assuming that memory is not a significant constraint. Create employee.xml as shown below. Create TestConfigurationForSpeed class as shown below. The configuration for speed is defined using XMLInputFactory2.configureForSpeed() (see line 19 … Read more

Woodstox : Handling Warning Using XMLReporter

Overview This article demonstrates the usage of XMLReporter in handling warning during StAX parsing. Create employee.dtd as shown below. Note that the entity ‘commonAddress’ is defined twice in the DTD (see lines 5-6 below). This will throw a warning condition during parsing. Create employee.xml as shown below. Create TestWarning as shown below. Define a custom … Read more

Woodstox : Exploring Validation Errors Using ValidationProblem

Overview In this article, we shall demonstrate how details of validation error can be obtained by using ValidationProblem class. Create the employee.dtd as shown below. It defines the employee element that contains id, name and salary sub-elements. Create invalidEmployee.xml as shown below. Note that it is not in accordance with employee.dtd described above as it … Read more

Woodstox : Handling Exceptions Related to Mal-Formed XML

Overview In this article, we shall demonstrate handling of exception when XML is not well formed. Create employee.xml as shown below. Note that this XML document is not well-formed e.g. the ‘salary’ end element is not properly closed (see line 4 below). Create TestXmlException class. Note that XMLStreamException is caught and error message is redirected … Read more

Woodstox : Validate XML generated by Woodstox

Overview In this article we shall perform validation of generated XML by XMLStreamWriter . This demonstrates Woodstox’ validation capabilities while generating XML output. Create employee.dtd as shown below. It defines the employee element that contains id, name and salary sub-elements. Create TestValidationXmlStreamWriter as shown below. Create a valid XML as per the DTD as shown … Read more

Woodstox : Validate against RelaxNG Schema

Overview This article demonstrates how to validate an XML document against an RelaxNG Schema by using Woodstox. See relaxng.org’s homepage for further details on RelaxNG XML schema specification. Create employee.rng as shown below. It defines the employee element that contains id, name and salary sub-elements. Create validEmployee.xml as shown below. It is in accordance with … Read more

Woodstox : Validate against XML Schema

Overview This article demonstrates how to validate an XML document against an XML Schema by using Woodstox. Create employeeSchema.xml as shown below. It defines the employee element that contains id, name and salary sub-elements. Create validEmployee.xml as shown below. It is in accordance with employeeSchema.xml described above. Create invalidEmployee.xml as shown below. Note that it … Read more

Woodstox : Validate against DTD

Overview This article demonstrates how to validate an XML document against a DTD by using Woodstox. Create employee.dtd as shown below. It defines the employee element that contains id, name and salary sub-elements. Create validEmployee.xml as shown below. It is in accordance with employee.dtd described above. Create invalidEmployee.xml as shown below. Note that it is … Read more

Woodstox : Bind Namespace Prefix and URI During XML Generation Using StAX

Overview This article demonstrates how Woodstox can be used to bind namespace URI and prefix during XML generation. Create TestBindingPrefix class as shown below. Prefix is bound using the following API methods: XMLStreamWriter2.setPrefix() method for setting the prefix and URI(e.g. see line 28 below) XMLStreamWriter2.setDefaultNamespace() to set the default namespace URI (see line 21 below) … Read more

Woodstox : Generate XML Using StAX

Overview Woodstox StAX Streaming API can be used to generate XML document. The key classes responsible for generating XML content are XMLOutputFactory2 and XMLStreamWriter2 . Create TestGenerateXml class as shown below. Point the outstream to Console output (see line 16 below). The following methods are used for XML content generation: create start element using writeStartElement() … Read more