IT. Expert System.

Java Standard Edition (SE)

XMLOutputFactory


compact2, compact3
javax.xml.stream

Class 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.isRepairingNamespacesdefaults prefixes on the output sideBooleanFalseYes

    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
    Version:
    1.2
    See Also:
    XMLInputFactory, XMLEventWriter, XMLStreamWriter
    • 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
    • Constructor Detail

      • XMLOutputFactory

        protected XMLOutputFactory()
    • Method Detail

      • 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 service-provider loading facilities, defined by the ServiceLoader class, to attempt to locate and load an implementation of the service using the default loading mechanism: 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, the system-default implementation is returned.
        • 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 - in case of service configuration error or if the implementation is not available or cannot be instantiated.
      • 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.

        This method uses the following ordered lookup procedure to determine the XMLOutputFactory implementation class to load:

        • Use the value of the system property identified by factoryId.
        • 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 given factoryId.
        • If factoryId is "javax.xml.stream.XMLOutputFactory", use the service-provider loading facilities, 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.
        API Note:
        The parameter factoryId defined here is inconsistent with that of other JAXP factories where the first parameter is fully qualified factory class name that provides implementation of the factory.

        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.

        Parameters:
        factoryId - Name of the factory to find, same as a property name
        classLoader - classLoader to use
        Returns:
        the factory implementation
        Throws:
        FactoryConfigurationError - in case of service configuration error or if the implementation is not available or cannot be instantiated.
      • 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 property
        value - 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


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 2863 / 159533513. Delta: 0.04245 с