Using the Streaming API for XML StAX 4-19
4.3.6 Closing the Output Stream
It is good programming practice to explicitly close the XMLStreamWriter when you are finished with it to free up resources. To close the writer, use the
XMLStreamWriter.close method, as shown in the following example:
Close the XMLStreamWriter to free up resources xmlw.close;
4.4 Properties Defined for the XMLInputFactory Interface
Table 4–2 lists the standard properties you can set when using the XMLInputFactory
to generate an XMLStreamReader or XMLEventReader object. All properties in
Table 4–2 are preceded with javax.xml.stream, such as
javax.xml.stream.isValidating.
4.5 Properties Defined for the XMLOutputFactory Interface
Table 4–3 lists the standard properties you can set when using the
XMLOutputFactory to generate an XMLStreamWriter or XMLEventWriter object. All properties in
Table 4–3 are preceded with javax.xml.stream, such as
javax.xml.stream.isValidating.
Table 4–2 Standard XMLInputFactory Properties
Property Description
Return Type Default
Value isValidating
Specifies whether implementation-specific DTD validation is enabled or disabled.
Boolean False
isNamespaceAware Specifies whether namespace processing is
enabled or disabled. Used for XML 1.0 support.
Boolean True
isCoalescing Specifies whether to coalesce adjacent
adjacent character data. Boolean
False isReplacingEntityReferences
Specifies whether internal entity references should be replaced with their replacement
text and reported as characters. Boolean
True isSupportingExternalEntities Specifies whether to resolve external
parsed entities. Boolean
False supportDTD
Specifies whether the processor used is one that supports or does not support DTDs.
Boolean True
reporter Specifies the implementation of
javax.xml.stream.XMLReporter that should be used.Specifies the implementation of
javax.xml.stream.XMLReporter that should be used.
XMLReporter Null
resolver Specifies the implementation of
javax.xml.stream.XMLResolver that should be used.
XMLResolver Null
allocator Specifies the implementation of
javax.xml.stream.util.XMLEventAllocator that should be used.
util.XMLEventAllocator Null
4-20 Programming XML for Oracle WebLogic Server
Table 4–3 Standard XMLOutputFactory Properties
Property Description
Return Type Default
Value isRepairingNamespaces
Specifies that the writer use default namespace prefix declarations.
There are strict rules about how the StAX processor repairs namespaces and prefixes when
generating XML. For details, see the StAX specification at
http:www.jcp.orgenjsrdetail?id= 173
. Boolean
False
5
Using Advanced XML APIs 5-1
5
Using Advanced XML APIs
The following sections provide information about using advanced XML APIs:
■
Section 5.1, Using the Java API for XML Registries JAXR API