Java Reference
In-Depth Information
<book xmlns="http://ns.example.com/books"
xmlns:b="http://ns.example.com/books"
sku="345_iui">
<b:title>White Noise</b:title>
</book>
You can also use the
setPrefix
method to indicate the prefix to use on elements. Set
the
javax.xml.stream.isRepairingNamespaces
on the factory to true to add the default
namespace to the root element:
<book xmlns="http://ns.example.com/books"
xmlns:b="http://ns.example.com/books"
sku="345_iui">
If you do not set the
javax.xml.stream.isRepairingNamespaces
on the factory, or set it to
false, the default namespace is left out, resulting in a book element that looks like this:
<?xml version="1.0"?>
<!--Powered by StAX-->
<book xmlns:b="http://ns.example.com/books" sku="345_iui">
//...
In general, when deciding between the two modes, if you want to be able to modify the event
stream and want the most flexible API, choose Iterator. If you want the fastest possible per-
formance and the smallest footprint, use the Cursor API.