You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Andreas Hartmann <an...@apache.org> on 2009/03/11 11:14:32 UTC
Prefixes for JCR node names
Hi Sling devs,
sorry if this basic question has been answered before – I didn't find
anything.
If I want to distinguish JCR item names belonging to my application from
user-generated items, my first idea would be to use a prefix:
/tutorial
/app:content > nt:resource
/content
/chapter1
(How) is this compatible with Sling's URI mapping? I did some tests, but
somehow I couldn't access a prefixed node (like app:content) over HTTP.
Strangely, when I mount the repository via WebDAV, the folder name is
"app/content" (not a hierarchy, but as the name of a single folder).
Is it discouraged to use node name prefixes in Sling? Should I use a
naming convention instead, e.g. appContent?
TIA!
-- Andreas
--
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01
Re: Prefixes for JCR node names
Posted by Rory Douglas <ro...@oracle.com>.
I believe you can access namespace-prefixed nodes using the
namespace-mangling feature of the resource resolver, try:
/tutorial/_app_content/content/chapter1
You can change the regex used for this mangling in the Felix webconsole
configuration screen for "Apache Sling Resource Resolver"
However, it also sounds like perhaps you don't have an actual "app"
namepace, but rather a node name containing an escaped/transformed
prefix - I'm not familiar enough with Sling to know how this came
about. How did you create this test content tree?
Regards,
Rory
Andreas Hartmann wrote:
> Hi Sling devs,
>
> sorry if this basic question has been answered before – I didn't find
> anything.
>
> If I want to distinguish JCR item names belonging to my application
> from user-generated items, my first idea would be to use a prefix:
>
> /tutorial
> /app:content > nt:resource
> /content
> /chapter1
>
> (How) is this compatible with Sling's URI mapping? I did some tests,
> but somehow I couldn't access a prefixed node (like app:content) over
> HTTP. Strangely, when I mount the repository via WebDAV, the folder
> name is "app/content" (not a hierarchy, but as the name of a single
> folder).
>
> Is it discouraged to use node name prefixes in Sling? Should I use a
> naming convention instead, e.g. appContent?
>
> TIA!
>
> -- Andreas
>
>
Re: Prefixes for JCR node names
Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, Mar 11, 2009 at 11:14 AM, Andreas Hartmann <an...@apache.org> wrote:
> Hi Sling devs,
>
> sorry if this basic question has been answered before – I didn't find
> anything.
>
> If I want to distinguish JCR item names belonging to my application from
> user-generated items, my first idea would be to use a prefix:
>
> /tutorial
> /app:content > nt:resource
> /content
> /chapter1
I would rather not use namespace prefixes, as they cause all sorts of
problems over http and with URs (as you have already seen ;-)).
Sling's escaping is "/app:content" => "/_app_content" and you can see
it for example with standard nt:files, where the subnode is always
"jcr:content" => "_jcr_content".
Instead of a prefix, I would use a "reserved" name, such as "appdata",
or model the hierarchy in a way that application data and user
generated content is never on the same layer. You could also use node
types as markers (eg. "my:AppContent" or "my:UserGeneratedContent"),
albeit these are not visible by just looking at the path (which can be
simpler for a simple parsing routine in client-side javascript, for
example).
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com