You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Carsten Ziegeler <cz...@apache.org> on 2008/04/14 14:19:40 UTC

Node name generation

Hi,

I'm currently working on SLING-354 [1]

My idea is to rename the parameter as discussed to "nameHint" with the 
semantics that this hint is used as specified if it is a valid node 
name. Invalid characters will be replaced with a "_".
If a node with the name already exists, a number is prefixed to the node 
name (like it is currently done).

Now, there is already a filtering for node names if the special 
properties like jcr:title, name etc. are used. But this filtering is 
much more strikter: it always creates a lower case name and replaces 
valid characters (like spaces etc.) as well.

I think we should have the same behaviour when it comes to filtering and 
think we should only replace invalid characters.

WDYT?

Regards
Carsten

[1] https://issues.apache.org/jira/browse/SLING-354
-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Node name generation

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, Apr 14, 2008 at 4:12 PM, Felix Meschberger <fm...@gmail.com> wrote:

> ... In fact, I would be rather strict in accepting "valid" characters,
>  probably reducing the accepted set to just [ a..z, A..Z, 0..9 ]. Not
>  sure about the case mangling. But if we apply it in one place (when
>  mangling a title), we should also apply it in the other place (when
>  mangling the "nameHint". Whatever we do, it should be consistent....

As mentioned in this thread, the final goal is to create good URLs
from free-form data, so I think the current filtering, as applied to
parameters like "title" etc., is fine.

If Carsten needs precise control on the node names being created, I'd
suggest having three ways to specify the names of created nodes:

1) nodeName parameter -> no filtering at all, client must provide a
valid JCR name

2) derive the name from title, description, etc. parameters -> as now,
filtering creates "good" URLs,  all lower case, restricted to
characters a to z, 0 to 9 and underscore.

3) nameHint parameter: same as 2) but takes precedence on those parameters.

In this way we have consistent filtering between 2) and 3), nice URLs,
and a way to specifiy exact node names if needed.

-Bertrand

Re: Node name generation

Posted by Carsten Ziegeler <cz...@apache.org>.
Felix Meschberger wrote:
> 
>> If a node with the name already exists, a number is prefixed to the node 
>> name (like it is currently done).
> 
> I assume you mean "suffix", that is _append_ the number, right ?
> 
Yes, you're right :) (I was looking at the wrong code...)

> 
> In fact, I would be rather strict in accepting "valid" characters,
> probably reducing the accepted set to just [ a..z, A..Z, 0..9 ]. Not
> sure about the case mangling. But if we apply it in one place (when
> mangling a title), we should also apply it in the other place (when
> mangling the "nameHint". Whatever we do, it should be consistent.
> 
Yepp, see my other mail for a new proposal :)

Carsten

-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Node name generation

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Am Montag, den 14.04.2008, 14:19 +0200 schrieb Carsten Ziegeler:
> Hi,
> 
> I'm currently working on SLING-354 [1]
> 
> My idea is to rename the parameter as discussed to "nameHint" with the 
> semantics that this hint is used as specified if it is a valid node 
> name. Invalid characters will be replaced with a "_".

In this respect, I would also treat blanks as "invalid" as it tends to
create issues with URLs.

> If a node with the name already exists, a number is prefixed to the node 
> name (like it is currently done).

I assume you mean "suffix", that is _append_ the number, right ?

> Now, there is already a filtering for node names if the special 
> properties like jcr:title, name etc. are used. But this filtering is 
> much more strikter: it always creates a lower case name and replaces 
> valid characters (like spaces etc.) as well.
> 
> I think we should have the same behaviour when it comes to filtering and 
> think we should only replace invalid characters.
> 
> WDYT?

+1

In fact, I would be rather strict in accepting "valid" characters,
probably reducing the accepted set to just [ a..z, A..Z, 0..9 ]. Not
sure about the case mangling. But if we apply it in one place (when
mangling a title), we should also apply it in the other place (when
mangling the "nameHint". Whatever we do, it should be consistent.

Regards
Felix


Re: Node name generation

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Am Montag, den 14.04.2008, 14:32 +0200 schrieb Alexander Klimetschek:
> A minor, but very helpful addition:
> 
> For languages with Umlaute and other special characters, it would be  
> cool to support translating them into the nearest normal letter  
> instead of "_". For example, "ä" -> "ae" etc.

Not sure, whether this is really worth the effort ;-)

Regards
Felix

> A simple way would be to provide a (configurable) map for looking up  
> the translated variant of the character. If nothing is found in the  
> map, "_" will be used as default?
> 
> Question is how to make the map extensible, so that new translations  
> can be easily added once someone comes up with a new one (and sling  
> core developers don't have to bother with those additions ;-). Maybe  
> through an OSGi service? Or could it be stored in the JCR repository?
> 
> Alex
> 
> Am 14.04.2008 um 14:19 schrieb Carsten Ziegeler:
> > Hi,
> >
> > I'm currently working on SLING-354 [1]
> >
> > My idea is to rename the parameter as discussed to "nameHint" with  
> > the semantics that this hint is used as specified if it is a valid  
> > node name. Invalid characters will be replaced with a "_".
> > If a node with the name already exists, a number is prefixed to the  
> > node name (like it is currently done).
> >
> > Now, there is already a filtering for node names if the special  
> > properties like jcr:title, name etc. are used. But this filtering is  
> > much more strikter: it always creates a lower case name and replaces  
> > valid characters (like spaces etc.) as well.
> >
> > I think we should have the same behaviour when it comes to filtering  
> > and think we should only replace invalid characters.
> >
> > WDYT?
> >
> > Regards
> > Carsten
> >
> > [1] https://issues.apache.org/jira/browse/SLING-354
> > -- 
> > Carsten Ziegeler
> > cziegeler@apache.org
> 
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
> 
>  >> Day JCR Cup 08 | Win a MacBook Pro: http://dev.day.com/ <<
> 
> 
> 
> 


Re: Node name generation

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Am Montag, den 14.04.2008, 16:52 +0200 schrieb Alexander Klimetschek:
> >> There should be some central API (OSGi service) that can be called
> >> anywhere and that creates a valid name, acts in case of an existing
> >> node in the repository, etc. All the stuff. There could be a very
> >> simple implementation in Sling, and others could extend it by
> >> replacing it with their own bundle. WDYT?
> >
> > If you could come up with such a service, we might certainly consider
> > adding it.
> 
> Argh, I shouldn't have raised my arm. ;-)

LOL

> Actually, actually my minimum requirement is that the auto-naming code  
> is available as a (static) utility method for all code running in  
> sling, because you need it very often. And nobody should be forced to  
> re-invent the idea of valid characters every time....

We could add such a method to the JcrResourceUtil class of the
jcr/resource module. This class contains other related methods such as
getParent(String path) and getName(String path). So this would be kind
of a fit.


Regards
Felix


Re: Node name generation

Posted by Alexander Klimetschek <ak...@day.com>.
Hi Felix!

Am 14.04.2008 um 16:16 schrieb Felix Meschberger:
>> How does Sling handle the
>> translation of URIs to resource/JCR paths?
>
> The URI is tested unmodified on a character level. There is no URI
> mangling to get the node name applied.
>
>> What if there are ambiguities?
>
> There are "none". Either a node with that exact name exists or not.
>
>> IMHO the create-valid-and-unique-node-name mechanism
>> should also consider URIs, because that's what website users see in
>> the end.
>
> The goal of URIs is to read and send them easily. For this reason any
> special characters, in particular characters needing some form of
> encoding should be prevented (if at all possible).

The one important thing is that people cannot create nodes that aren't  
accessible later because they are not a valid URI. But as I can see,  
the set of all possible URIs is contained within JCR paths. The  
proposed auto-naming is restricted to an even smaller set (a-z,0-9)  
that is fully contained within the URI set. Then there won't be any  
problems.

>> There should be some central API (OSGi service) that can be called
>> anywhere and that creates a valid name, acts in case of an existing
>> node in the repository, etc. All the stuff. There could be a very
>> simple implementation in Sling, and others could extend it by
>> replacing it with their own bundle. WDYT?
>
> If you could come up with such a service, we might certainly consider
> adding it.

Argh, I shouldn't have raised my arm. ;-)

Actually, actually my minimum requirement is that the auto-naming code  
is available as a (static) utility method for all code running in  
sling, because you need it very often. And nobody should be forced to  
re-invent the idea of valid characters every time....

The extensibility for special umlaute would be a nice-to-have, but  
less important.

Alex

--
Alexander Klimetschek
alexander.klimetschek@day.com

 >> Day JCR Cup 08 | Win a MacBook Pro: http://dev.day.com/ <<





Re: Node name generation

Posted by Carsten Ziegeler <cz...@apache.org>.
Felix Meschberger wrote:
> Hi,
> 
> Am Montag, den 14.04.2008, 16:27 +0200 schrieb Carsten Ziegeler:
>> Felix Meschberger wrote:
>>> The goal of URIs is to read and send them easily. For this reason any
>>> special characters, in particular characters needing some form of
>>> encoding should be prevented (if at all possible).
>> The current filter allows these characters:
>> "abcdefghijklmnopqrstuvwxyz0123456789_"
>>
>> Now, I still think we have two use cases:
>> a) generate url friendly node names
>> b) try to generate exactly a specified node name
>>
>> We can't unify these two cases into one. Therefore I think we should 
>> handle the "nameHint" different from the support of using "jcr:title" 
>> and the like to defer the node name.
>> Perhaps renaming "nodeName" to "nodeHint" was wrong after all...
>>
>> Ok, my proposal is:
>> a) sling:post:nodeName - only invalid chars are filtered
>> b) sling:post:nameHint, jcr:title etc. are handled all the same (as they 
>> are already today)
>>
>> WDYT?
> 
> +1 (Bertrand suggested essentially the same, so I am also +1 to
> Bertrand's proposal ;-) ). Withone catch, though: Can we find something
> else than "nodeName" ? How about "exactName" ?
Just name? We have nameHint, so "name" would be correct, I think

> 
> And then, I would not filter or otherwise mangle the exact name (this is
> the difference to Betrand's proposal) and rather fail if the name is
> invalid.
> 
Yepp, I agree. I'll update the issue and then change the impl.

Thanks
Carsten

-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Node name generation

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Am Dienstag, den 15.04.2008, 11:27 +0200 schrieb Carsten Ziegeler:
> Ok, anyonw *against* using "name" and "nameHint"? I'll commit a version 
> using these parameter names. If anyone has a good reason for better 
> names, I'm happy to change the impl.

+1 for these names ;-)

Thanks and Regards
Felix

> 
> Carsten
> 
> David Nuescheler wrote:
> > hi guys,
> > 
> > personally, i don't care too much as long as we keep the "simple case" namely
> > where the default namehint (if it is not explicitly set) is derived
> > from jcr:title, title etc..
> > 
> > of course, i think we should (like for all form elements that have a special
> > meaning to sling) prefix it with "sling:"
> > 
> > my personal favorite would be "sling:nameHint"
> > 
> > regards,
> > david
> > 
> > On Mon, Apr 14, 2008 at 5:05 PM, Carsten Ziegeler <cz...@apache.org> wrote:
> >> Bertrand Delacretaz wrote:
> >>
> >>> On Mon, Apr 14, 2008 at 4:38 PM, Felix Meschberger <fm...@gmail.com>
> >> wrote:
> >>>
> >>>> ...Can we find something
> >>>>  else than "nodeName" ? How about "exactName" ?...
> >>>>
> >>> nodeName is IMHO better, as the parameter describes the name of the
> >>> created node...exactName could be the exact name of your sister ;-)
> >>>
> >>>
> >>  :)
> >>
> >>
> >>> But to be consistent, nameHint should be nodeNameHint maybe. A bit
> >>> longish but very clear.
> >>>
> >>>
> >>  Ok, we should either use "nodeNameHint" and "nodeName"
> >>
> >>   or
> >>
> >>  "name" and "nameHint"
> >>
> >>  From those two options I would prefer the first one.
> >>
> >>  Carsten
> >>
> >>
> >>
> >>>> ... And then, I would not filter or otherwise mangle the exact name
> >> (this is
> >>>>  the difference to Betrand's proposal) and rather fail if the name is
> >>>>  invalid....
> >>>>
> >>> We are in agreement, that's what I suggested, no filtering for nodeName.
> >>>
> >>> -Bertrand
> >>>
> >>>
> >>
> >>
> >>  --
> >>  Carsten Ziegeler
> >>  cziegeler@apache.org
> >>
> > 
> > 
> > 
> 
> 


Re: Node name generation

Posted by Carsten Ziegeler <cz...@apache.org>.
Ok, anyonw *against* using "name" and "nameHint"? I'll commit a version 
using these parameter names. If anyone has a good reason for better 
names, I'm happy to change the impl.

Carsten

David Nuescheler wrote:
> hi guys,
> 
> personally, i don't care too much as long as we keep the "simple case" namely
> where the default namehint (if it is not explicitly set) is derived
> from jcr:title, title etc..
> 
> of course, i think we should (like for all form elements that have a special
> meaning to sling) prefix it with "sling:"
> 
> my personal favorite would be "sling:nameHint"
> 
> regards,
> david
> 
> On Mon, Apr 14, 2008 at 5:05 PM, Carsten Ziegeler <cz...@apache.org> wrote:
>> Bertrand Delacretaz wrote:
>>
>>> On Mon, Apr 14, 2008 at 4:38 PM, Felix Meschberger <fm...@gmail.com>
>> wrote:
>>>
>>>> ...Can we find something
>>>>  else than "nodeName" ? How about "exactName" ?...
>>>>
>>> nodeName is IMHO better, as the parameter describes the name of the
>>> created node...exactName could be the exact name of your sister ;-)
>>>
>>>
>>  :)
>>
>>
>>> But to be consistent, nameHint should be nodeNameHint maybe. A bit
>>> longish but very clear.
>>>
>>>
>>  Ok, we should either use "nodeNameHint" and "nodeName"
>>
>>   or
>>
>>  "name" and "nameHint"
>>
>>  From those two options I would prefer the first one.
>>
>>  Carsten
>>
>>
>>
>>>> ... And then, I would not filter or otherwise mangle the exact name
>> (this is
>>>>  the difference to Betrand's proposal) and rather fail if the name is
>>>>  invalid....
>>>>
>>> We are in agreement, that's what I suggested, no filtering for nodeName.
>>>
>>> -Bertrand
>>>
>>>
>>
>>
>>  --
>>  Carsten Ziegeler
>>  cziegeler@apache.org
>>
> 
> 
> 


-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Node name generation

Posted by David Nuescheler <da...@day.com>.
hi guys,

personally, i don't care too much as long as we keep the "simple case" namely
where the default namehint (if it is not explicitly set) is derived
from jcr:title, title etc..

of course, i think we should (like for all form elements that have a special
meaning to sling) prefix it with "sling:"

my personal favorite would be "sling:nameHint"

regards,
david

On Mon, Apr 14, 2008 at 5:05 PM, Carsten Ziegeler <cz...@apache.org> wrote:
> Bertrand Delacretaz wrote:
>
> > On Mon, Apr 14, 2008 at 4:38 PM, Felix Meschberger <fm...@gmail.com>
> wrote:
> >
> >
> > > ...Can we find something
> > >  else than "nodeName" ? How about "exactName" ?...
> > >
> >
> > nodeName is IMHO better, as the parameter describes the name of the
> > created node...exactName could be the exact name of your sister ;-)
> >
> >
>  :)
>
>
> > But to be consistent, nameHint should be nodeNameHint maybe. A bit
> > longish but very clear.
> >
> >
>  Ok, we should either use "nodeNameHint" and "nodeName"
>
>   or
>
>  "name" and "nameHint"
>
>  From those two options I would prefer the first one.
>
>  Carsten
>
>
>
> >
> > > ... And then, I would not filter or otherwise mangle the exact name
> (this is
> > >  the difference to Betrand's proposal) and rather fail if the name is
> > >  invalid....
> > >
> >
> > We are in agreement, that's what I suggested, no filtering for nodeName.
> >
> > -Bertrand
> >
> >
>
>
>
>  --
>  Carsten Ziegeler
>  cziegeler@apache.org
>



-- 
Visit: http://dev.day.com/ - Day JCR Cup 08 - Win a MacBook Pro

Re: Node name generation

Posted by Carsten Ziegeler <cz...@apache.org>.
Bertrand Delacretaz wrote:
> On Mon, Apr 14, 2008 at 4:38 PM, Felix Meschberger <fm...@gmail.com> wrote:
> 
>> ...Can we find something
>>  else than "nodeName" ? How about "exactName" ?...
> 
> nodeName is IMHO better, as the parameter describes the name of the
> created node...exactName could be the exact name of your sister ;-)
> 
:)

> But to be consistent, nameHint should be nodeNameHint maybe. A bit
> longish but very clear.
> 
Ok, we should either use "nodeNameHint" and "nodeName"

   or

"name" and "nameHint"

 From those two options I would prefer the first one.

Carsten

>> ... And then, I would not filter or otherwise mangle the exact name (this is
>>  the difference to Betrand's proposal) and rather fail if the name is
>>  invalid....
> 
> We are in agreement, that's what I suggested, no filtering for nodeName.
> 
> -Bertrand
> 


-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Node name generation

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, Apr 14, 2008 at 4:38 PM, Felix Meschberger <fm...@gmail.com> wrote:

> ...Can we find something
>  else than "nodeName" ? How about "exactName" ?...

nodeName is IMHO better, as the parameter describes the name of the
created node...exactName could be the exact name of your sister ;-)

But to be consistent, nameHint should be nodeNameHint maybe. A bit
longish but very clear.

> ... And then, I would not filter or otherwise mangle the exact name (this is
>  the difference to Betrand's proposal) and rather fail if the name is
>  invalid....

We are in agreement, that's what I suggested, no filtering for nodeName.

-Bertrand

Re: Node name generation

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Am Montag, den 14.04.2008, 16:27 +0200 schrieb Carsten Ziegeler:
> Felix Meschberger wrote:
> > 
> > The goal of URIs is to read and send them easily. For this reason any
> > special characters, in particular characters needing some form of
> > encoding should be prevented (if at all possible).
> 
> The current filter allows these characters:
> "abcdefghijklmnopqrstuvwxyz0123456789_"
> 
> Now, I still think we have two use cases:
> a) generate url friendly node names
> b) try to generate exactly a specified node name
> 
> We can't unify these two cases into one. Therefore I think we should 
> handle the "nameHint" different from the support of using "jcr:title" 
> and the like to defer the node name.
> Perhaps renaming "nodeName" to "nodeHint" was wrong after all...
> 
> Ok, my proposal is:
> a) sling:post:nodeName - only invalid chars are filtered
> b) sling:post:nameHint, jcr:title etc. are handled all the same (as they 
> are already today)
> 
> WDYT?

+1 (Bertrand suggested essentially the same, so I am also +1 to
Bertrand's proposal ;-) ). Withone catch, though: Can we find something
else than "nodeName" ? How about "exactName" ?

And then, I would not filter or otherwise mangle the exact name (this is
the difference to Betrand's proposal) and rather fail if the name is
invalid.

Regards
Felix


Re: Node name generation

Posted by Carsten Ziegeler <cz...@apache.org>.
Felix Meschberger wrote:
> 
> The goal of URIs is to read and send them easily. For this reason any
> special characters, in particular characters needing some form of
> encoding should be prevented (if at all possible).

The current filter allows these characters:
"abcdefghijklmnopqrstuvwxyz0123456789_"

Now, I still think we have two use cases:
a) generate url friendly node names
b) try to generate exactly a specified node name

We can't unify these two cases into one. Therefore I think we should 
handle the "nameHint" different from the support of using "jcr:title" 
and the like to defer the node name.
Perhaps renaming "nodeName" to "nodeHint" was wrong after all...

Ok, my proposal is:
a) sling:post:nodeName - only invalid chars are filtered
b) sling:post:nameHint, jcr:title etc. are handled all the same (as they 
are already today)

WDYT?
Carsten
-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Node name generation

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Am Montag, den 14.04.2008, 14:59 +0200 schrieb Alexander Klimetschek:
> Am 14.04.2008 um 14:42 schrieb Carsten Ziegeler:
> > Alexander Klimetschek wrote:
> >> A minor, but very helpful addition:
> >> For languages with Umlaute and other special characters, it would  
> >> be cool to support translating them into the nearest normal letter  
> >> instead of "_". For example, "ä" -> "ae" etc.
> > Hmm, yes and no :) Now, these characters are valid from the jcr pov  
> > (at least I think they are), so there is no need to convert them.
> 
> JCR Names are XML Names, which have no intuitive description (not to  
> me), just a Unicode table of allowed characters:
> 
> Name/NameChar
> http://www.w3.org/TR/REC-xml/#NT-NameChar
> 
> Table of allowed characters:
> http://www.w3.org/TR/REC-xml/#NT-Letter
> 
> But are they very different from URIs?

The character set for URIs is not Unicode ...

>  How does Sling handle the  
> translation of URIs to resource/JCR paths? 

The URI is tested unmodified on a character level. There is no URI
mangling to get the node name applied.

> What if there are ambiguities?

There are "none". Either a node with that exact name exists or not.

>  IMHO the create-valid-and-unique-node-name mechanism  
> should also consider URIs, because that's what website users see in  
> the end.

The goal of URIs is to read and send them easily. For this reason any
special characters, in particular characters needing some form of
encoding should be prevented (if at all possible).

> 
> > On the other hand it might be usefull to create "pretty names" or  
> > web friendly names; but I'm not sure if this is the task of Sling to  
> > do this.
> 
> Yes, in my experience all content-creating applications that want to  
> have meaningful URLs have the problem of finding a valid JCR/URI name  
> for a given user input. Having it part of the framework is IMHO  
> extremely useful.
> 
> > We *could* create such a hook, but as this is only used in the case  
> > of the post servlet and not if nodes are created through any other  
> > way, I tend to leave this to the client code calling the post servlet.
> 
> There should be some central API (OSGi service) that can be called  
> anywhere and that creates a valid name, acts in case of an existing  
> node in the repository, etc. All the stuff. There could be a very  
> simple implementation in Sling, and others could extend it by  
> replacing it with their own bundle. WDYT?

If you could come up with such a service, we might certainly consider
adding it.

Regards
Felix


Re: Node name generation

Posted by Alexander Klimetschek <ak...@day.com>.
Am 14.04.2008 um 14:42 schrieb Carsten Ziegeler:
> Alexander Klimetschek wrote:
>> A minor, but very helpful addition:
>> For languages with Umlaute and other special characters, it would  
>> be cool to support translating them into the nearest normal letter  
>> instead of "_". For example, "ä" -> "ae" etc.
> Hmm, yes and no :) Now, these characters are valid from the jcr pov  
> (at least I think they are), so there is no need to convert them.

JCR Names are XML Names, which have no intuitive description (not to  
me), just a Unicode table of allowed characters:

Name/NameChar
http://www.w3.org/TR/REC-xml/#NT-NameChar

Table of allowed characters:
http://www.w3.org/TR/REC-xml/#NT-Letter

But are they very different from URIs? How does Sling handle the  
translation of URIs to resource/JCR paths? What if there are  
ambiguities? IMHO the create-valid-and-unique-node-name mechanism  
should also consider URIs, because that's what website users see in  
the end.

> On the other hand it might be usefull to create "pretty names" or  
> web friendly names; but I'm not sure if this is the task of Sling to  
> do this.

Yes, in my experience all content-creating applications that want to  
have meaningful URLs have the problem of finding a valid JCR/URI name  
for a given user input. Having it part of the framework is IMHO  
extremely useful.

> We *could* create such a hook, but as this is only used in the case  
> of the post servlet and not if nodes are created through any other  
> way, I tend to leave this to the client code calling the post servlet.

There should be some central API (OSGi service) that can be called  
anywhere and that creates a valid name, acts in case of an existing  
node in the repository, etc. All the stuff. There could be a very  
simple implementation in Sling, and others could extend it by  
replacing it with their own bundle. WDYT?

Alex

--
Alexander Klimetschek
alexander.klimetschek@day.com

 >> Day JCR Cup 08 | Win a MacBook Pro: http://dev.day.com/ <<





Re: Node name generation

Posted by Carsten Ziegeler <cz...@apache.org>.
Alexander Klimetschek wrote:
> A minor, but very helpful addition:
> 
> For languages with Umlaute and other special characters, it would be 
> cool to support translating them into the nearest normal letter instead 
> of "_". For example, "ä" -> "ae" etc.
> 
Hmm, yes and no :) Now, these characters are valid from the jcr pov (at 
least I think they are), so there is no need to convert them.

On the other hand it might be usefull to create "pretty names" or web 
friendly names; but I'm not sure if this is the task of Sling to do 
this. We *could* create such a hook, but as this is only used in the 
case of the post servlet and not if nodes are created through any other 
way, I tend to leave this to the client code calling the post servlet.

Carsten

> A simple way would be to provide a (configurable) map for looking up the 
> translated variant of the character. If nothing is found in the map, "_" 
> will be used as default?
> 
> Question is how to make the map extensible, so that new translations can 
> be easily added once someone comes up with a new one (and sling core 
> developers don't have to bother with those additions ;-). Maybe through 
> an OSGi service? Or could it be stored in the JCR repository?
> 



-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Node name generation

Posted by Alexander Klimetschek <ak...@day.com>.
A minor, but very helpful addition:

For languages with Umlaute and other special characters, it would be  
cool to support translating them into the nearest normal letter  
instead of "_". For example, "ä" -> "ae" etc.

A simple way would be to provide a (configurable) map for looking up  
the translated variant of the character. If nothing is found in the  
map, "_" will be used as default?

Question is how to make the map extensible, so that new translations  
can be easily added once someone comes up with a new one (and sling  
core developers don't have to bother with those additions ;-). Maybe  
through an OSGi service? Or could it be stored in the JCR repository?

Alex

Am 14.04.2008 um 14:19 schrieb Carsten Ziegeler:
> Hi,
>
> I'm currently working on SLING-354 [1]
>
> My idea is to rename the parameter as discussed to "nameHint" with  
> the semantics that this hint is used as specified if it is a valid  
> node name. Invalid characters will be replaced with a "_".
> If a node with the name already exists, a number is prefixed to the  
> node name (like it is currently done).
>
> Now, there is already a filtering for node names if the special  
> properties like jcr:title, name etc. are used. But this filtering is  
> much more strikter: it always creates a lower case name and replaces  
> valid characters (like spaces etc.) as well.
>
> I think we should have the same behaviour when it comes to filtering  
> and think we should only replace invalid characters.
>
> WDYT?
>
> Regards
> Carsten
>
> [1] https://issues.apache.org/jira/browse/SLING-354
> -- 
> Carsten Ziegeler
> cziegeler@apache.org

--
Alexander Klimetschek
alexander.klimetschek@day.com

 >> Day JCR Cup 08 | Win a MacBook Pro: http://dev.day.com/ <<