The NamespaceSupport Class
NamespaceSupport
provides a stack that can track the namespaces in
scope at various points in the document. To use it, push a new
context at the beginning of each element's namespace mappings, and
pop it at the end of each element. Each startPrefixMapping( )
invocation should
call declarePrefix( )
to add a
new mapping to the NamespaceSupport
object. Then at any
point where you need to figure out to which URI a prefix is bound,
you can call getPrefix( )
. The
empty string indicates the default namespace. The getter methods
can then tell you the prefix that is mapped to any URI or the URI
that is mapped to any prefix at each point in the document. If you
reuse the same NamespaceSupport
object for multiple documents, be sure to call reset( )
between documents.
package org.xml.sax.helpers; public classNamespaceSupport
{ public final static StringXMLNS
="http://www.w3.org/XML/1998/namespace"; public NamespaceSupport( ); public voidreset
( ); public voidpushContext
( ); public voidpopContext
( ); public booleandeclarePrefix
(Stringprefix
, Stringuri
); public String[ ]processName
(StringqualifiedName
, String[ ]parts
, booleanisAttribute
); public StringgetURI
(Stringprefix
); public EnumerationgetPrefixes
( ); public StringgetPrefix
(Stringuri
); public EnumerationgetPrefixes
(Stringuri
); public EnumerationgetDeclaredPrefixes
( ); }