addNamespace (NamespaceContextImpl - JavaScript)

Adds or replaces a namespace.

Defined in

NamespaceContextImpl

Syntax

addNamespace(prefix:string, uri:string) : void

Parameters Description
prefix A valid prefix.
URI A URI to be associated with the prefix.

Usage

The name and prefix form a namespace. The namespace is added if the prefix does not already exist in the namespace context. If the prefix already exists, this namespace replaces the existing namespace.

Examples

This button onclick event creates a namespace context if it does not yet exist then adds or replaces a namespace. The prefix and URI for the namespace are global objects defined elsewhere on the page before the button is clicked. The namespace context is a global object so other code can use it.
if(sessionScope.ns == null) {
	sessionScope.ns = new NamespaceContextImpl();
}
sessionScope.ns.addNamespace(
	requestScope.prefix, requestScope.uri);