/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * Copyright (c) 2009 by Oracle Corporation. All Rights Reserved. */ package javax.xml.stream; import javax.xml.transform.Result; /** * 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 NameBehaviorReturn typeDefault ValueRequired
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.

* * @version 1.2 * @author Copyright (c) 2009 by Oracle Corporation. All Rights Reserved. * @see XMLInputFactory * @see XMLEventWriter * @see XMLStreamWriter * @since 1.6 */ public abstract class XMLOutputFactory { /** * Property used to set prefix defaulting on the output side */ public static final String IS_REPAIRING_NAMESPACES= "javax.xml.stream.isRepairingNamespaces"; static final String DEFAULIMPL = "com.sun.xml.internal.stream.XMLOutputFactoryImpl"; protected XMLOutputFactory(){} /** * Create a new instance of the factory. * @throws FactoryConfigurationError if an instance of this factory cannot be loaded */ public static XMLOutputFactory newInstance() throws FactoryConfigurationError { return FactoryFinder.find(XMLOutputFactory.class, DEFAULIMPL); } /** * 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: *

*