public class NamespaceManager
extends java.lang.Object
XMLObject.
Code which mutates the state of an XMLObject such that XML namespace-related data is also logically changed, should call the appropriate method, based on the type of change being made.
| Modifier and Type | Field and Description |
|---|---|
private java.util.Set<Namespace> |
attrNames
Registered namespaces of attribute names.
|
private java.util.Map<java.lang.String,Namespace> |
attrValues
Registered namespaces of attribute values.
|
private Namespace |
contentValue
Registered namespaces of content values.
|
private java.util.Set<Namespace> |
decls
Explicitly declared namespaces.
|
static java.lang.String |
DEFAULT_NS_TOKEN
The token used to represent the default namespace in
getNonVisibleNamespacePrefixes(). |
private Namespace |
elementName
XMLObject name namespace.
|
private Namespace |
elementType
XMLObject type namespace.
|
private XMLObject |
owner
The owning XMLObject.
|
private static Namespace |
XML_NAMESPACE
The 'xml' namespace.
|
private static Namespace |
XSI_NAMESPACE
The 'xsi' namespace.
|
| Constructor and Description |
|---|
NamespaceManager(XMLObject owningObject)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
addNamespace(java.util.Set<Namespace> namespaces,
Namespace newNamespace)
Add a Namespace to a set of Namespaces.
|
private void |
addPrefixes(java.util.Set<java.lang.String> prefixes,
java.util.Collection<Namespace> namespaces)
Add the prefixes from a collection of namespaces to a set of prefixes.
|
private Namespace |
buildNamespace(javax.xml.namespace.QName name)
Build a
Namespace instance from a QName. |
private boolean |
checkQName(javax.xml.namespace.QName name)
Check whether the supplied QName contains non-empty namespace info and should
be managed by the namespace manager.
|
void |
deregisterAttributeName(javax.xml.namespace.QName attributeName)
Deregister a namespace-qualified attribute name.
|
void |
deregisterAttributeValue(java.lang.String attributeID)
Deregister a QName attribute value.
|
void |
deregisterContentValue()
Deregister a QName content value.
|
void |
deregisterNamespaceDeclaration(Namespace namespace)
Deregister a namespace declaration.
|
static java.lang.String |
generateAttributeID(javax.xml.namespace.QName name)
From a QName representing a qualified attribute name, generate an attribute ID
suitable for use in
registerAttributeValue(String, QName)
and deregisterAttributeValue(String). |
java.util.Set<Namespace> |
getAllNamespacesInSubtreeScope()
Get the set of all namespaces which are in scope within the subtree rooted
at the owning XMLObject.
|
private Namespace |
getElementNameNamespace()
Return a Namespace instance representing the namespace of the element name.
|
private Namespace |
getElementTypeNamespace()
Return a Namespace instance representing the namespace of the element type, if known.
|
java.util.Set<Namespace> |
getNamespaceDeclarations()
Get the set of namespace declarations registered on the owning XMLObject.
|
java.util.Set<Namespace> |
getNamespaces()
Get the set of namespaces currently in use on the owning XMLObject.
|
private java.util.Set<Namespace> |
getNonVisibleNamespaceCandidates()
Get the set of non-visibly used namespaces used on the owning XMLObject (only the owner,
not the owner's children).
|
java.util.Set<java.lang.String> |
getNonVisibleNamespacePrefixes()
Obtain the set of namespace prefixes used in a non-visible manner on owning XMLObject
and its children.
|
java.util.Set<Namespace> |
getNonVisibleNamespaces()
Obtain the set of namespaces used in a non-visible manner on owning XMLObject
and its children.
|
XMLObject |
getOwner()
Get the owning XMLObject instance.
|
private java.util.Set<Namespace> |
getVisibleNamespaces()
Get the set of namespaces which are currently visibly-used on the owning XMLObject (only the owner,
not its children).
|
private java.util.Set<Namespace> |
mergeNamespaceCollections(java.util.Collection<Namespace>... namespaces)
Merge 2 or more Namespace collections into a single set.
|
void |
registerAttributeName(javax.xml.namespace.QName attributeName)
Register a namespace-qualified attribute name.
|
void |
registerAttributeValue(java.lang.String attributeID,
javax.xml.namespace.QName attributeValue)
Register a QName attribute value.
|
void |
registerContentValue(javax.xml.namespace.QName content)
Register a QName element content value.
|
void |
registerElementName(javax.xml.namespace.QName name)
Register the owning XMLObject's element name.
|
void |
registerElementType(javax.xml.namespace.QName type)
Register the owning XMLObject's element type, if explicitly declared via an xsi:type.
|
void |
registerNamespaceDeclaration(Namespace namespace)
Register a namespace declaration.
|
private void |
removeNamespace(java.util.Set<Namespace> namespaces,
Namespace oldNamespace)
Remove a Namespace from a set of Namespaces.
|
public static final java.lang.String DEFAULT_NS_TOKEN
getNonVisibleNamespacePrefixes().private static final Namespace XML_NAMESPACE
private static final Namespace XSI_NAMESPACE
@Nonnull private final XMLObject owner
private Namespace elementName
private Namespace elementType
@Nonnull private final java.util.Set<Namespace> decls
@Nonnull private final java.util.Set<Namespace> attrNames
@Nonnull private final java.util.Map<java.lang.String,Namespace> attrValues
private Namespace contentValue
public NamespaceManager(@Nonnull
XMLObject owningObject)
owningObject - the XMLObject whose namespace info is to be managed@Nonnull
@NotEmpty
public static java.lang.String generateAttributeID(@Nonnull
javax.xml.namespace.QName name)
registerAttributeValue(String, QName)
and deregisterAttributeValue(String).name - attribute name as a QName@Nonnull public XMLObject getOwner()
@Nonnull public java.util.Set<Namespace> getNamespaces()
public void registerNamespaceDeclaration(@Nonnull
Namespace namespace)
namespace - the namespace to registerpublic void deregisterNamespaceDeclaration(@Nonnull
Namespace namespace)
namespace - the namespace to deregister@Nonnull public java.util.Set<Namespace> getNamespaceDeclarations()
public void registerAttributeName(@Nonnull
javax.xml.namespace.QName attributeName)
attributeName - the attribute name to registerpublic void deregisterAttributeName(@Nonnull
javax.xml.namespace.QName attributeName)
attributeName - the attribute name to deregisterpublic void registerAttributeValue(@Nonnull
java.lang.String attributeID,
@Nonnull
javax.xml.namespace.QName attributeValue)
attributeID - unique identifier for the attribute within the XMLObject's content modelattributeValue - the QName value to registerpublic void deregisterAttributeValue(@Nonnull
java.lang.String attributeID)
attributeID - unique identifier for the attribute within the XMLObject's content modelpublic void registerContentValue(@Nonnull
javax.xml.namespace.QName content)
content - the QName value to registerpublic void deregisterContentValue()
@Nonnull public java.util.Set<java.lang.String> getNonVisibleNamespacePrefixes()
The primary use case for this information is to support the inclusive prefixes information that may optionally be supplied as a part of XML exclusive canonicalization.
@Nonnull public java.util.Set<Namespace> getNonVisibleNamespaces()
The primary use case for this information is to support the inclusive prefixes information that may optionally be supplied as a part of XML exclusive canonicalization.
@Nonnull public java.util.Set<Namespace> getAllNamespacesInSubtreeScope()
public void registerElementName(@Nonnull
javax.xml.namespace.QName name)
name - the element name to registerpublic void registerElementType(@Nullable
javax.xml.namespace.QName type)
type - the element type to register@Nullable private Namespace getElementNameNamespace()
@Nullable private Namespace getElementTypeNamespace()
@Nonnull private Namespace buildNamespace(@Nonnull javax.xml.namespace.QName name)
Namespace instance from a QName.name - the source QNameprivate void addNamespace(@Nonnull
java.util.Set<Namespace> namespaces,
@Nullable
Namespace newNamespace)
namespaces - the set of namespacesnewNamespace - the namespace to add to the setprivate void removeNamespace(@Nonnull
java.util.Set<Namespace> namespaces,
@Nullable
Namespace oldNamespace)
namespaces - the set of namespacesoldNamespace - the namespace to add to the set@Nonnull private java.util.Set<Namespace> mergeNamespaceCollections(java.util.Collection<Namespace>... namespaces)
namespaces - list of Namespaces to merge@Nonnull private java.util.Set<Namespace> getVisibleNamespaces()
@Nonnull private java.util.Set<Namespace> getNonVisibleNamespaceCandidates()
private void addPrefixes(@Nonnull
java.util.Set<java.lang.String> prefixes,
@Nonnull
java.util.Collection<Namespace> namespaces)
DEFAULT_NS_TOKEN.prefixes - the set of prefixes to which to addnamespaces - the source set of Namespacesprivate boolean checkQName(@Nullable
javax.xml.namespace.QName name)
name - the QName to check