Each repository has a single, persistent namespace registry represented by the NamespaceRegistry object, accessed via Workspace.getNamespaceRegistry(). The following describes the methods of NamespaceRegistry supported in level 1. NamespaceRegistry also has other methods that are supported in level 2. In level 1 repositories these methods either do nothing or throw an exception. See 7.2 Adding and Deleting Namespaces for more details.
javax.jcr. |
|
String[] |
getPrefixes() Returns an array holding all currently registered prefixes. A RepositoryException is thrown if an error occurs. |
String[] |
getURIs() Returns an array holding all currently registered URIs. A RepositoryException is thrown if an error occurs. |
String |
getURI(String prefix) Returns the URI to which the given prefix is mapped. If a mapping with the specified prefix does not exist, a NamespaceException is thrown. A RepositoryException is thrown if another error occurs. |
String |
getPrefix(String uri) Returns the prefix which is mapped to the given uri. If a mapping with the specified uri does not exist, a NamespaceException is thrown A RepositoryException is thrown if another error occurs. |
A registered prefix can be used in the name of any node or property in the repository. The prefix serves as shorthand for the URI to which it is mapped. Because the space of URIs is universally managed, the combination of the per-repository namespace and the larger URI namespace can be used to provide universal uniqueness of node or property names. Of course, just as in the case of XML namespaces, ensuring this universal uniqueness requires applications to map their application-specific prefixes to URIs that are uniquely identified with that particular application.
The namespace registry always contains at least the following built-in mappings:
jcr -> http://www.jcp.org/jcr/1.0
Reserved for items defined within built-in node types. For example jcr:content.
nt -> http://www.jcp.org/jcr/nt/1.0
Reserved for the names of built-in primary node types.
mix -> http://www.jcp.org/jcr/mix/1.0
Reserved for the names of built-in mixin node types.
xml -> http://www.w3.org/XML/1998/namespace
Reserved for reasons of compatibility with XML. This prefix should not be used by clients of the API in the names of normal nodes or properties, since doing so will cause problems on export to XML.
“” (the empty prefix) -> “” (the empty URI)
This makes the default namespace the empty URI. In effect this means that a name without a prefix is identical in both its prefixed form and in its fully qualified form (i.e. when it is stored internally as URI plus local name). See 6.6.1 Internal Storage of Names and Values.
In a level 1 repository there is no provision for adding new namespaces to the registry (or deleting namespaces from it), this functionality is part of level 2 (see 7.2 Adding and Deleting Namespaces). However, a level 1 implementation may provide any number of built-in namespaces, in addition to the five required ones listed above. As well, level 1 supports the temporary assignment of new prefixes to existing namespaces within the scope of a particular Session (see immediately below).