You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Michal Hybler <m....@email.cz> on 2007/03/22 13:58:05 UTC

Fofbidden characters in node names

Could someone tell me all characters which are forbidden in node names ....
as " : etc. 

Thanks for help Michal
-- 
View this message in context: http://www.nabble.com/Fofbidden-characters-in-node-names-tf3446647.html#a9611853
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Fofbidden characters in node names

Posted by Paco Avila <pa...@git.es>.
El jue, 22-03-2007 a las 18:21 +0100, Julian Reschke escribió:
> Paco Avila schrieb:
> > El jue, 22-03-2007 a las 05:58 -0700, Michal Hybler escribió:
> >> Could someone tell me all characters which are forbidden in node names ....
> >> as " : etc. 
> > 
> > 
> > public static String escape(String name) {
> > 		log.debug("escape("+name+")");
> > 		String ret = name.replace('/', ' ');
> > 		ret = ret.replace(':', ' ');
> > 		ret = ret.replace('[', ' ');
> > 		ret = ret.replace(']', ' ');
> > 		ret = ret.replace('*', ' ');
> > 		ret = ret.replace('\'', ' ');
> > 		ret = ret.replace('"', ' ');
> > 		ret = ret.replace('|', ' ');
> > 		ret = ret.trim();
> > 		log.debug("escape: "+ret);
> > 		return ret;
> > 	}
> 
> Nit: I wouldn't call this method "escape", because it really doesn't 
> escape. Better to avoid confusion here :-)

I know. My initial try was to escape this chars, with no results :(

-- 
GIT Consultors S.L.
c\ Francesc Rover 2-B
07003 Palma de Mallorca
(Illes Balears)


Re: Fofbidden characters in node names

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 3/22/07, Jukka Zitting <ju...@gmail.com> wrote:
> On 3/22/07, Julian Reschke <ju...@gmx.de> wrote:
> > Paco Avila schrieb:
> > > El jue, 22-03-2007 a las 05:58 -0700, Michal Hybler escribió:
> > >> Could someone tell me all characters which are forbidden in node names ....
> > >> as " : etc.
> > >
> > > public static String escape(String name) {
> >
> > Nit: I wouldn't call this method "escape", because it really doesn't
> > escape. Better to avoid confusion here :-)
>
> Nit2: It doesn't actually produce valid JCR names in all cases.
>
> The rules for JCR names are essentially:

Nit3: The given rules are actually for JCR local names, that can be
prefixed with a valid XML prefix with a colon as the separator.

The JCR name parser class in [1] can validate a string as a JCR name
with just a single pass over all the characters in the string. Note
that this name parser still implements the original JCR 1.0 rule that
names consist of any Unicode characters instead of just the valid XML
character subset.

BR,

Jukka Zitting

[1] http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/name/ParsingNameResolver.java

Re: Fofbidden characters in node names

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 3/22/07, Julian Reschke <ju...@gmx.de> wrote:
> Paco Avila schrieb:
> > El jue, 22-03-2007 a las 05:58 -0700, Michal Hybler escribió:
> >> Could someone tell me all characters which are forbidden in node names ....
> >> as " : etc.
> >
> > public static String escape(String name) {
>
> Nit: I wouldn't call this method "escape", because it really doesn't
> escape. Better to avoid confusion here :-)

Nit2: It doesn't actually produce valid JCR names in all cases.

The rules for JCR names are essentially:

0) The name must have at least one character

1) The name must only contain valid XML characters, i.e. many control
and other special Unicode characters are excluded (note that JCR 1.0
allows all Unicode characters, but in practice and in JCR 1.0.1 only
XML characters are allowed)

2) The only allowed whitespace character is the space (#20)

3) The name must not start or end with a space

4) The name must not contain any of the following characters: /:[]*'"|

5) The name must not be "." or ".."

BR,

Jukka Zitting

Re: Fofbidden characters in node names

Posted by Julian Reschke <ju...@gmx.de>.
Paco Avila schrieb:
> El jue, 22-03-2007 a las 05:58 -0700, Michal Hybler escribió:
>> Could someone tell me all characters which are forbidden in node names ....
>> as " : etc. 
> 
> 
> public static String escape(String name) {
> 		log.debug("escape("+name+")");
> 		String ret = name.replace('/', ' ');
> 		ret = ret.replace(':', ' ');
> 		ret = ret.replace('[', ' ');
> 		ret = ret.replace(']', ' ');
> 		ret = ret.replace('*', ' ');
> 		ret = ret.replace('\'', ' ');
> 		ret = ret.replace('"', ' ');
> 		ret = ret.replace('|', ' ');
> 		ret = ret.trim();
> 		log.debug("escape: "+ret);
> 		return ret;
> 	}

Nit: I wouldn't call this method "escape", because it really doesn't 
escape. Better to avoid confusion here :-)

Best regards, Julian


Re: Fofbidden characters in node names

Posted by Paco Avila <pa...@git.es>.
El jue, 22-03-2007 a las 05:58 -0700, Michal Hybler escribió:
> Could someone tell me all characters which are forbidden in node names ....
> as " : etc. 


public static String escape(String name) {
		log.debug("escape("+name+")");
		String ret = name.replace('/', ' ');
		ret = ret.replace(':', ' ');
		ret = ret.replace('[', ' ');
		ret = ret.replace(']', ' ');
		ret = ret.replace('*', ' ');
		ret = ret.replace('\'', ' ');
		ret = ret.replace('"', ' ');
		ret = ret.replace('|', ' ');
		ret = ret.trim();
		log.debug("escape: "+ret);
		return ret;
	}

-- 
GIT Consultors S.L.
c\ Francesc Rover 2-B
07003 Palma de Mallorca
(Illes Balears)