You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Julian Reschke (Jira)" <ji...@apache.org> on 2026/01/10 12:47:00 UTC
[jira] [Comment Edited] (JCR-5140) Improve support for generating namespace prefixes
[ https://issues.apache.org/jira/browse/JCR-5140?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18023826#comment-18023826 ]
Julian Reschke edited comment on JCR-5140 at 1/10/26 12:46 PM:
---------------------------------------------------------------
trunk: [542d9af96|https://github.com/apache/jackrabbit/commit/542d9af96172ac59995c81454f5a8d84b88698f0]
2.22: [e0a5fa6a3|https://github.com/apache/jackrabbit/commit/e0a5fa6a377071959e340db5fdbc7b61666987cd]
was (Author: reschke):
trunk: [542d9af96|https://github.com/apache/jackrabbit/commit/542d9af96172ac59995c81454f5a8d84b88698f0]
> Improve support for generating namespace prefixes
> -------------------------------------------------
>
> Key: JCR-5140
> URL: https://issues.apache.org/jira/browse/JCR-5140
> Project: Jackrabbit Content Repository
> Issue Type: Task
> Components: jackrabbit-jcr-commons
> Reporter: Julian Reschke
> Assignee: Julian Reschke
> Priority: Major
> Fix For: 2.24, 2.23.3, 2.22.3
>
>
> There are a few use cases where a new namespace prefix needs to be computed for a given namespace name (this list may not be exhaustive):
> - when mapping expanded names to JCR names when the namespace name (URI) is not known in the repository (yet) - though that's a use case not supported in Oak, creating of new items with previously non-registered namespace is not possible
> - when importing content where namespace names (URIs) are known, but prefixes may be not
> - when looking up a name from the repository from a repo that persists names with prefixes, but the prefix is already locally mapped to a different namespace
> - when registering node types where the namespace name (such as defined in the CND) is new, but the "preferred" prefix is already in use) - note that this requires write access to the repository's namespace registry
> Automatically generating the prefixes has several commons problems:
> - consistency: generating prefixes in different places and/or based on previous state of the registry (such as by incrementing counters until new non-conflicting prefix found) causes prefix inconsistency across systems for no good reason
> - conciseness and readability: for certain namespaces, there are commonly used prefixes (such as in DC, XMPP etc), and it would be good to just use those when possible
> Proposal: have a single place that offers help for generating prefixes (this ticket is in JCR space as jackrabbit-jcr-commons already has NamespaceHelper, but of course the location can be discussed). -We may want to start in oak-commons, so that we can more quickly iterate in Oak, and then maybe later move this into JCR commons.-
> Blue print:
> {code:java}
> // Suggests a prefix for the given namespace, based on
> // well-known XML namespaces, or alternatively derived
> // from the namespace name.
> public static String suggestPrefix(String namespace);
> // as above, but will take exisiting prefixes into account
> // this would be for the case where the prefix already exists
> // but is mapped to a different namespace name.
> // Lookup for existing prefix so that we can abstract out the
> // actual JCR interface (to be discussed)
> public static String suggestPrefix(String namespace, Function<String, String> getNamespaceForPrefix);
> // maybe more helpers:
> public static boolean isValidNamespace(String namespace);
> public static Map.Entry<String, String> extractPrefixAndNamespace(String jcrName, Function<String, String> getNamespaceForPrefix);{code}
> We'd also need a hook to account for "internal", unless we want to hard-wire that into this.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)