A helper class for managing the declaration of namespaces.
A namespace is declared on a namespace context.
Namespace contexts are pushed on and popped off the namespace context stack.
A declared namespace will be in scope iff the context that it was declared on
has not been popped off the stack.
When instantiated the namespace stack consists of the root namespace context,
which contains, by default, the "xml" and "xmlns" declarations.
Namespaces may be declarations may be declared on the root context.
The root context cannot be popped but can be reset to contain just the
"xml" and "xmlns" declarations.
Implementation note: determining the prefix from a namespace URI
(or vice versa) is efficient when there are few namespace
declarations i.e. what is considered to be the case for namespace
declarations in 'average' XML documents. The look up of a namespace URI
given a prefix is performed in O(n) time. The look up of a prefix given
a namespace URI is performed in O(2n) time.
The implementation does not scale when there are many namespace
declarations. TODO: Use a hash map when there are many namespace
declarations.
author: Paul.Sandoz@Sun.Com |