com.sun.xml.bind.serializer
Interface NamespaceContext2

All Superinterfaces:
javax.xml.namespace.NamespaceContext
All Known Implementing Classes:
NamespaceContextImpl

Deprecated. in JAXB1.0.1

public interface NamespaceContext2
extends javax.xml.namespace.NamespaceContext

Maintains namespace<->prefix bindings.

This interface extends NamespaceContext and provides an additional functionality, which is necessary to declare namespaced attributes on elements. The added method is for self-consumption by the marshaller. This object is composed into a Serializer.

Since:
JAXB1.0

Method Summary
 java.lang.String declareNamespace(java.lang.String namespaceUri, boolean requirePrefix)
          Deprecated. Declares a new namespace binding within the current context.
 
Methods inherited from interface javax.xml.namespace.NamespaceContext
getNamespaceURI, getPrefix, getPrefixes
 

Method Detail

declareNamespace

java.lang.String declareNamespace(java.lang.String namespaceUri,
                                  boolean requirePrefix)
Deprecated. 
Declares a new namespace binding within the current context.

The prefix is automatically assigned by MarshallingContext. If a given namespace URI is already declared, nothing happens.

It is NOT an error to declare the same namespace URI more than once.

For marshalling to work correctly, all namespace bindings for an element must be declared between its startElement method and its endAttributes event. Calling the same method with the same parameter between the endAttributes and the endElement returns the same prefix.

Parameters:
requirePrefix - If this parameter is true, this method must assign a prefix to this namespace, even if it's already bound to the default namespace. IOW, this method will never return null if this flag is true. This functionality is necessary to declare namespace URI used for attribute names.
Returns:
returns the assigned prefix. If the namespace is bound to the default namespace, null is returned.