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)

For details of other XML generation API method see related article
here

The output of the program demonstrating binding of namespace prefix and URI is shown below.

In particular, note the namespace prefix ‘s’ and URI ‘http://www.studytrails.com’ in the generated XML.

Download Source Code for this Program

Leave a Comment