XML Generation For Binding Prefix Using Aalto

Overview This article demonstrates how Aalto 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.setDefaultNamespace() to set the default namespace URI (see line 21 below) XMLStreamWriter2.setPrefix() method for setting the prefix and URI(e.g. see line 28 below) … Read more

XML Generation Using Aalto

Overview This article describes how to generate XML using Aalto Aalto 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 … Read more

Asynchronous Parsing Using Aalto: Handling Errors

Overview This article demonstrates how to handle parsing related errors during asynchronous StAX parsing using Aalto. Create employee.xml as shown below. Note that the end tag for ‘salary’ element is incorrect (see line 4 below). Create TestAsyncParsingError class as shown below. The parsing is done using wrapper class (see this article for further details). Catch … Read more

Detailed Asynchronous StAX Parsing Using Aalto: Parsing Comments, Processing Instructions, CData and Entity References

Overview In the earlier article we explored basic asynchronous StAX parsing using Aalto. In this article we shall see how Aalto’s asynchronous StAX parsing can be used to parse XML comments, processing instructions, CData and entity references. Create employee.xml as shown below. It contains comment, processing instruction, CDATA and entity references (see lines 1,3,7-9 and … Read more

Using Aalto Wrapper Class For Asynchronous StAX Parsing

Overview The basics of asynchronous stax parsing using Aalto is covered in the article mentioned here . In that article, you will note that low level buffer manipulation is required to manage asynchronous stax parsing. However, Aalto’s unit test suite provides a very convenient wrapper class that internally handles the details of byte level management … Read more

Basics Of Asynchronous StAX Parsing Using Aalto

Overview Aalto provides a unique feature to parse XML documents asynchronously i.e. the InputStream is not blocked when performing StAX based parsing. For further details, please see Introduction to Asynchronous StAX Parsing Using Aalto This article demonstrates the programming aspects for using the asynchronous parsing feature of Aalto. Create employee.xml as shown below. This XML … Read more

Aalto StAX Parsing: Error Handling

Overview This article demonstrates how to handle parser related errors using Aalto StAX parser. Create employee.xml as shown below. Note that the ‘salary’ element is not properly closed (see line 4 below). Create TestErrorHandling as shown below. Catch the WFCException (see line 39 below)) which is short for ‘Well-Formedness Constraint violation’ exception. The output of … Read more

Aalto StAX Parsing: Reading Namespace

Overview This article demonstrates the how to read namespace related information using Aalto StAX parser. Create employee.xml as shown below. Note the namespace URI ‘https://studytrails.com’ (see line 1 below) and the namespace prefix ‘s’ used in all start and end elements. Create TestReadNamespace as shown below. Note that start element is obtained by using the … Read more

Aalto StAX Parsing: Reading XML Attribute

Overview This article demonstrates how to read the attributes of an XML element using Aalto StAX parser. Create employee.xml as shown below. Note the attribute name ‘id’ with value ‘1’ (see line 1 below) Create TestReadAttribute as shown below. Note that start element is obtained by using the StAX API (see lines 20-28 below). The … Read more