- All Known Implementing Classes:
NamespaceBinder.NamespaceSupport,NamespaceSupport
The prefix and namespace must be identical references for equal strings, thus
each string should be internalized (String.intern()).
- Author:
- Andy Clark, IBM, Ronald Brill
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe XML Namespace ("http://www.w3.org/XML/1998/namespace").static final StringXML Information Set REC namespace attributes (including those namedxmlns, whose [prefix] property has no value) have a namespace URI of "http://www.w3.org/2000/xmlns/". -
Method Summary
Modifier and TypeMethodDescriptionbooleandeclarePrefix(String prefix, String uri) Declares a Namespace prefix.getDeclaredPrefixAt(int index) Returns the prefix at the specified index in the current context.intReturns a count of locally declared prefixes, including the default prefix if bound.Looks up a prefix and gets the currently-mapped Namespace URI.voidReverts to the previous Namespace context.voidStarts a new Namespace context.voidreset()Resets this Namespace support object for reuse.
-
Field Details
-
XML_URI
The XML Namespace ("http://www.w3.org/XML/1998/namespace"). This is the Namespace URI that is automatically mapped to the "xml" prefix.- See Also:
-
XMLNS_URI
XML Information Set REC namespace attributes (including those namedxmlns, whose [prefix] property has no value) have a namespace URI of "http://www.w3.org/2000/xmlns/".- See Also:
-
-
Method Details
-
pushContext
void pushContext()Starts a new Namespace context.A new context should be pushed at the beginning of each XML element: the new context will automatically inherit the declarations of its parent context, but it will also keep track of which declarations were made within this context.
- See Also:
-
popContext
void popContext()Reverts to the previous Namespace context.The context should be popped at the end of each XML element. After popping the context, all Namespace prefix mappings that were previously in force are restored.
Users must not attempt to declare additional Namespace prefixes after popping a context unless another context is pushed first.
- See Also:
-
declarePrefix
Declares a Namespace prefix.This method declares a prefix in the current Namespace context; the prefix will remain in force until this context is popped, unless it is shadowed in a descendant context.
Note that to declare a default Namespace, use the empty string. The prefixes "xml" and "xmlns" cannot be rebound.
- Parameters:
prefix- the prefix to declare, ornullor empty string for the default namespaceuri- the Namespace URI to associate with the prefix- Returns:
trueif the prefix was legal,falseotherwise- See Also:
-
getURI
Looks up a prefix and gets the currently-mapped Namespace URI.This method looks up the prefix in the current context. If no mapping is found, this method will continue lookup in the parent context(s). Use the empty string (
"") for the default Namespace.- Parameters:
prefix- the prefix to look up- Returns:
- the associated Namespace URI, or
nullif the prefix is undeclared
-
getDeclaredPrefixCount
int getDeclaredPrefixCount()Returns a count of locally declared prefixes, including the default prefix if bound.- Returns:
- the count of locally declared prefixes
-
getDeclaredPrefixAt
Returns the prefix at the specified index in the current context.- Parameters:
index- the zero-based index position of the declared prefix- Returns:
- the prefix at the specified index, or
nullif out of bounds
-
reset
void reset()Resets this Namespace support object for reuse.It is necessary to invoke this method before reusing the Namespace support object for a new session.
Note that implementations of this method need to ensure that the declarations of the prefixes "xmlns" and "xml" remain available.
-