6.3.3 Session Namespace Remapping

Any registered namespace can be temporarily remapped to a new prefix within the scope of a particular Session.

javax.jcr.
Session

void

setNamespacePrefix(String prefix, String uri)

Within the scope of this Session, remaps a persistently registered namespace URI to the new prefix. The remapping only affects operations done through this session. To clear all remappings, the client must acquire a new Session.

A prefix that is currently already mapped to some URI (either persistently in the repository NamespaceRegistry or transiently within this Session) cannot be remapped to a new URI using this method, since this would make any content stored using the old URI unreadable. An attempt to do this will throw a NamespaceException.

As well, a NamespaceException will be thrown if an attempt is made to remap an existing namespace URI to a prefix beginning with the characters “xml” (in any combination of case).

A NamespaceException will also be thrown if the specified uri is not among those registered in the NamespaceRegistry.

A RepositoryException is thrown if another error occurs.

String[]

getNamespacePrefixes()

Returns all prefixes currently set for this Session. This includes all those registered in the NamespaceRegistry but not temporarily over-ridden by a Session.setNamespacePrefix, plus those currently set locally by Session.setNamespacePrefix.

A RepositoryException is thrown if an error occurs.

String

getNamespaceURI(String prefix)

Returns the URI to which the given prefix is mapped as currently set in this Session.

A NamespaceException is thrown if the specified prefix is unknown.

A RepositoryException is thrown if another error occurs.

String

getNamespacePrefix(String uri)

Returns the prefix to which the given URI is mapped as currently set in this Session.

A NamespaceException is thrown if the specified uri is unknown.

A RepositoryException is thrown if another error occurs.