- java.lang.Object
-
- javax.xml.stream.XMLOutputFactory
-
public abstract class XMLOutputFactory extends Object
Defines an abstract implementation of a factory for getting XMLEventWriters and XMLStreamWriters. The following table defines the standard properties of this specification. Each property varies in the level of support required by each implementation. The level of support required is described in the 'Required' column.Configuration parameters 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",new Boolean(true|false));
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.
- Since:
- 1.6
- See Also:
XMLInputFactory
,XMLEventWriter
,XMLStreamWriter
-
-
Field Summary
Fields Modifier and Type Field and Description static String
IS_REPAIRING_NAMESPACES
Property used to set prefix defaulting on the output side
-
Constructor Summary
Constructors Modifier Constructor and Description protected
XMLOutputFactory()
-
Method Summary
Methods Modifier and Type Method and Description abstract XMLEventWriter
createXMLEventWriter(OutputStream stream)
Create a new XMLEventWriter that writes to a streamabstract XMLEventWriter
createXMLEventWriter(OutputStream stream, String encoding)
Create a new XMLEventWriter that writes to a streamabstract XMLEventWriter
createXMLEventWriter(Result result)
Create a new XMLEventWriter that writes to a JAXP result.abstract XMLEventWriter
createXMLEventWriter(Writer stream)
Create a new XMLEventWriter that writes to a writerabstract XMLStreamWriter
createXMLStreamWriter(OutputStream stream)
Create a new XMLStreamWriter that writes to a streamabstract XMLStreamWriter
createXMLStreamWriter(OutputStream stream, String encoding)
Create a new XMLStreamWriter that writes to a streamabstract XMLStreamWriter
createXMLStreamWriter(Result result)
Create a new XMLStreamWriter that writes to a JAXP result.abstract XMLStreamWriter
createXMLStreamWriter(Writer stream)
Create a new XMLStreamWriter that writes to a writerabstract Object
getProperty(String name)
Get a feature/property on the underlying implementationabstract boolean
isPropertySupported(String name)
Query the set of properties that this factory supports.static XMLOutputFactory
newFactory()
Create a new instance of the factory.static XMLOutputFactory
newFactory(String factoryId, ClassLoader classLoader)
Create a new instance of the factory.static XMLOutputFactory
newInstance()
Create a new instance of the factory.static XMLInputFactory
newInstance(String factoryId, ClassLoader classLoader)
Deprecated.This method has been deprecated because it returns an instance of XMLInputFactory, which is of the wrong class. Use the new methodnewFactory(java.lang.String, java.lang.ClassLoader)
instead.abstract void
setProperty(String name, Object value)
Allows the user to set specific features/properties on the underlying implementation.
-
-
-
Field Detail
-
IS_REPAIRING_NAMESPACES
public static final String IS_REPAIRING_NAMESPACES
Property used to set prefix defaulting on the output side- See Also:
- Constant Field Values
-
-
Method Detail
-
newInstance
public static XMLOutputFactory newInstance() throws FactoryConfigurationError
Create a new instance of the factory.- Throws:
FactoryConfigurationError
- if an instance of this factory cannot be loaded
-
newFactory
public static XMLOutputFactory newFactory() throws FactoryConfigurationError
Create a new instance of the factory. This static method creates a new factory instance. This method uses the following ordered lookup procedure to determine the XMLOutputFactory implementation class to load: Use the javax.xml.stream.XMLOutputFactory system property. Use the properties file "lib/stax.properties" in the JRE directory. This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above. Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The Services API will look for a classname in the file META-INF/services/javax.xml.stream.XMLOutputFactory in jars available to the runtime. Platform default XMLOutputFactory instance. Once an application has obtained a reference to a XMLOutputFactory it can use the factory to configure and obtain stream instances. Note that this is a new method that replaces the deprecated newInstance() method. No changes in behavior are defined by this replacement method relative to the deprecated method.- Throws:
FactoryConfigurationError
- if an instance of this factory cannot be loaded
-
newInstance
public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError
Deprecated. This method has been deprecated because it returns an instance of XMLInputFactory, which is of the wrong class. Use the new methodnewFactory(java.lang.String, java.lang.ClassLoader)
instead.Create a new instance of the factory.- Parameters:
factoryId
- Name of the factory to find, same as a property nameclassLoader
- classLoader to use- Returns:
- the factory implementation
- Throws:
FactoryConfigurationError
- if an instance of this factory cannot be loaded
-
newFactory
public static XMLOutputFactory newFactory(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError
Create a new instance of the factory. If the classLoader argument is null, then the ContextClassLoader is used. Note that this is a new method that replaces the deprecated newInstance(String factoryId, ClassLoader classLoader) method. No changes in behavior are defined by this replacement method relative to the deprecated method.- Parameters:
factoryId
- Name of the factory to find, same as a property nameclassLoader
- classLoader to use- Returns:
- the factory implementation
- Throws:
FactoryConfigurationError
- if an instance of this factory cannot be loaded
-
createXMLStreamWriter
public abstract XMLStreamWriter createXMLStreamWriter(Writer stream) throws XMLStreamException
Create a new XMLStreamWriter that writes to a writer- Parameters:
stream
- the writer to write to- Throws:
XMLStreamException
-
createXMLStreamWriter
public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream) throws XMLStreamException
Create a new XMLStreamWriter that writes to a stream- Parameters:
stream
- the stream to write to- Throws:
XMLStreamException
-
createXMLStreamWriter
public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream, String encoding) throws XMLStreamException
Create a new XMLStreamWriter that writes to a stream- Parameters:
stream
- the stream to write toencoding
- the encoding to use- Throws:
XMLStreamException
-
createXMLStreamWriter
public abstract XMLStreamWriter createXMLStreamWriter(Result result) throws XMLStreamException
Create a new XMLStreamWriter that writes to a JAXP result. This method is optional.- Parameters:
result
- the result to write to- Throws:
UnsupportedOperationException
- if this method is not supported by this XMLOutputFactoryXMLStreamException
-
createXMLEventWriter
public abstract XMLEventWriter createXMLEventWriter(Result result) throws XMLStreamException
Create a new XMLEventWriter that writes to a JAXP result. This method is optional.- Parameters:
result
- the result to write to- Throws:
UnsupportedOperationException
- if this method is not supported by this XMLOutputFactoryXMLStreamException
-
createXMLEventWriter
public abstract XMLEventWriter createXMLEventWriter(OutputStream stream) throws XMLStreamException
Create a new XMLEventWriter that writes to a stream- Parameters:
stream
- the stream to write to- Throws:
XMLStreamException
-
createXMLEventWriter
public abstract XMLEventWriter createXMLEventWriter(OutputStream stream, String encoding) throws XMLStreamException
Create a new XMLEventWriter that writes to a stream- Parameters:
stream
- the stream to write toencoding
- the encoding to use- Throws:
XMLStreamException
-
createXMLEventWriter
public abstract XMLEventWriter createXMLEventWriter(Writer stream) throws XMLStreamException
Create a new XMLEventWriter that writes to a writer- Parameters:
stream
- the stream to write to- Throws:
XMLStreamException
-
setProperty
public abstract void setProperty(String name, Object value) throws IllegalArgumentException
Allows the user to set specific features/properties on the underlying implementation.- Parameters:
name
- The name of the propertyvalue
- The value of the property- Throws:
IllegalArgumentException
- if the property is not supported
-
getProperty
public abstract Object getProperty(String name) throws IllegalArgumentException
Get a feature/property on the underlying implementation- Parameters:
name
- The name of the property- Returns:
- The value of the property
- Throws:
IllegalArgumentException
- if the property is not supported
-
isPropertySupported
public abstract boolean isPropertySupported(String name)
Query the set of properties that this factory supports.- Parameters:
name
- The name of the property (may not be null)- Returns:
- true if the property is supported and false otherwise
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/xml/stream/xmloutputfactory.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.