public abstract class XMLOutputFactory extends Object
Property Name | Behavior | Return type | Default Value | Required |
---|---|---|---|---|
javax.xml.stream.isRepairingNamespaces | defaults prefixes on the output side | Boolean | False | Yes |
The following paragraphs describe the namespace and prefix repair algorithm:
The property can be set with the following code line: setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.TRUE);
This property specifies that the writer default namespace prefix declarations. The default value is false.
If a writer isRepairingNamespaces it will create a namespace declaration on the current StartElement for any attribute that does not currently have a namespace declaration in scope. If the StartElement has a uri but no prefix specified a prefix will be assigned, if the prefix has not been declared in a parent of the current StartElement it will be declared on the current StartElement. If the defaultNamespace is bound and in scope and the default namespace matches the URI of the attribute or StartElement QName no prefix will be assigned.
If an element or attribute name has a prefix, but is not bound to any namespace URI, then the prefix will be removed during serialization.
If element and/or attribute names in the same start or empty-element tag are bound to different namespace URIs and are using the same prefix then the element or the first occurring attribute retains the original prefix and the following attributes have their prefixes replaced with a new prefix that is bound to the namespace URIs of those attributes.
If an element or attribute name uses a prefix that is bound to a different URI than that inherited from the namespace context of the parent of that element and there is no namespace declaration in the context of the current element then such a namespace declaration is added.
If an element or attribute name is bound to a prefix and there is a namespace declaration that binds that prefix to a different URI then that namespace declaration is either removed if the correct mapping is inherited from the parent context of that element, or changed to the namespace URI of the element or attribute using that prefix.
Modifier and Type | Field | Description |
---|---|---|
static final String |
IS_REPAIRING_NAMESPACES |
Property used to set prefix defaulting on the output side |
Modifier | Constructor | Description |
---|---|---|
protected |
Protected constructor to prevent instantiation. |
Modifier and Type | Method | Description |
---|---|---|
abstract XMLEventWriter |
createXMLEventWriter |
Create a new XMLEventWriter that writes to a stream |
abstract XMLEventWriter |
createXMLEventWriter |
Create a new XMLEventWriter that writes to a stream |
abstract XMLEventWriter |
createXMLEventWriter |
Create a new XMLEventWriter that writes to a writer |
abstract XMLEventWriter |
createXMLEventWriter |
Create a new XMLEventWriter that writes to a JAXP result. |
abstract XMLStreamWriter |
createXMLStreamWriter |
Create a new XMLStreamWriter that writes to a stream |
abstract XMLStreamWriter |
createXMLStreamWriter |
Create a new XMLStreamWriter that writes to a stream |
abstract XMLStreamWriter |
createXMLStreamWriter |
Create a new XMLStreamWriter that writes to a writer |
abstract XMLStreamWriter |
createXMLStreamWriter |
Create a new XMLStreamWriter that writes to a JAXP result. |
abstract Object |
getProperty |
Get a feature/property on the underlying implementation |
abstract boolean |
isPropertySupported |
Query the set of properties that this factory supports. |
static XMLOutputFactory |
newDefaultFactory() |
Creates a new instance of the XMLOutputFactory builtin system-default implementation. |
static XMLOutputFactory |
newFactory() |
Creates a new instance of the factory. |
static XMLOutputFactory |
newFactory |
Create a new instance of the factory. |
static XMLOutputFactory |
newInstance() |
Creates a new instance of the factory in exactly the same manner as the newFactory() method. |
static XMLInputFactory |
newInstance |
Deprecated. This method has been deprecated because it returns an instance of XMLInputFactory, which is of the wrong class. |
abstract void |
setProperty |
Allows the user to set specific features/properties on the underlying implementation. |
public static final String IS_REPAIRING_NAMESPACES
protected XMLOutputFactory()
newFactory()
instead.public static XMLOutputFactory newDefaultFactory()
XMLOutputFactory
builtin system-default implementation.XMLOutputFactory
builtin system-default implementation.public static XMLOutputFactory newInstance() throws FactoryConfigurationError
newFactory()
method.XMLOutputFactory
FactoryConfigurationError
- if an instance of this factory cannot be loadedpublic static XMLOutputFactory newFactory() throws FactoryConfigurationError
XMLOutputFactory
implementation class to load. Once an application has obtained a reference to a XMLOutputFactory
, it can use the factory to configure and obtain stream instances.
XMLOutputFactory
FactoryConfigurationError
- in case of service configuration error or if the implementation is not available or cannot be instantiated.@Deprecated(since="1.7") public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError
newFactory(java.lang.String, java.lang.ClassLoader)
instead.factoryId
- Name of the factory to find, same as a property nameclassLoader
- classLoader to useFactoryConfigurationError
- if an instance of this factory cannot be loadedpublic static XMLOutputFactory newFactory(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError
This method uses the following ordered lookup procedure to determine the XMLOutputFactory implementation class to load:
factoryId
. Use the value of the property factoryId
set in the configuration file, jaxp.properties by default. If the file exists and the property factoryId
is specified in the file, its value will be used as the implementation class.
If factoryId
is "javax.xml.stream.XMLOutputFactory", use the service-provider loading facility, defined by the ServiceLoader
class, to attempt to locate and load an implementation of the service using the specified ClassLoader
. If classLoader
is null, the default loading mechanism will apply: That is, the service-provider loading facility will use the current thread's context class loader to attempt to load the service. If the context class loader is null, the system class loader will be used.
Otherwise, throws a FactoryConfigurationError
.
Note that this is a new method that replaces the deprecated newInstance(String factoryId, ClassLoader classLoader)
method. The original method was incorrectly defined to return XMLInputFactory.
factoryId
- Name of the factory to find, same as a property nameclassLoader
- classLoader to useFactoryConfigurationError
- in case of service configuration error or if the implementation is not available or cannot be instantiated.public abstract XMLStreamWriter createXMLStreamWriter(Writer stream) throws XMLStreamException
stream
- the writer to write toXMLStreamWriter
XMLStreamException
- if an error occurspublic abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream) throws XMLStreamException
stream
- the stream to write toXMLStreamWriter
XMLStreamException
- if an error occurspublic abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream, String encoding) throws XMLStreamException
stream
- the stream to write toencoding
- the encoding to useXMLStreamWriter
XMLStreamException
- if an error occurspublic abstract XMLStreamWriter createXMLStreamWriter(Result result) throws XMLStreamException
result
- the result to write toXMLStreamWriter
UnsupportedOperationException
- if this method is not supported by this XMLOutputFactoryXMLStreamException
- if an error occurspublic abstract XMLEventWriter createXMLEventWriter(Result result) throws XMLStreamException
result
- the result to write toXMLEventWriter
UnsupportedOperationException
- if this method is not supported by this XMLOutputFactoryXMLStreamException
- if an error occurspublic abstract XMLEventWriter createXMLEventWriter(OutputStream stream) throws XMLStreamException
stream
- the stream to write toXMLEventWriter
XMLStreamException
- if an error occurspublic abstract XMLEventWriter createXMLEventWriter(OutputStream stream, String encoding) throws XMLStreamException
stream
- the stream to write toencoding
- the encoding to useXMLEventWriter
XMLStreamException
- if an error occurspublic abstract XMLEventWriter createXMLEventWriter(Writer stream) throws XMLStreamException
stream
- the stream to write toXMLEventWriter
XMLStreamException
- if an error occurspublic abstract void setProperty(String name, Object value) throws IllegalArgumentException
name
- The name of the propertyvalue
- The value of the propertyIllegalArgumentException
- if the property is not supportedpublic abstract Object getProperty(String name) throws IllegalArgumentException
name
- The name of the propertyIllegalArgumentException
- if the property is not supportedpublic abstract boolean isPropertySupported(String name)
name
- The name of the property (may not be null)
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.xml/javax/xml/stream/XMLOutputFactory.html