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)

Create TestEntityReference as shown below.

Set the property
XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES
as false (see line 17 below).

Get the parsed value of entity reference using
XmlStreamReader.getLocalName()
(see line 29 below).

The output of the program demonstrating parsing of entity reference is shown below.

In particular note the entity reference in output (see line 8 below)

Download Source Code for this Program

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Bitnami