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

Aalto StAX Parsing: Peek To Next Element

Overview Aalto provides a feature to peek into the next XML element from the current XML element. This is achieved by using XMLEventReader.peek() method. Note that according JSR-173 specification, XmlEventReader.peek() method returns the next element but does not take it off the stream. This sample program demonstrates how to peek into the next XML element. … Read more

Aalto StAX Parsing: Entity Reference

Overview This article demonstrates how to parse entity references using Aalto StAX parser. Note that as of Aalto version 0.9.6, replacing of entity references is not supported. Parsing shall only return the entity reference itself. Create employee.xml as shown below. Note that an entity reference ‘entity-reference1’ is used for address element (see line 5 below) … Read more