jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Guggisberg" <stefan.guggisb...@day.com>
Subject Re: Problem with SPI Pathfactory and absolute path
Date Mon, 02 Jun 2008 14:01:55 GMT
hi pierre

On Mon, Jun 2, 2008 at 2:35 PM, Pierre Leman <pierrelem@gmail.com> wrote:
> Hi,
>
>
> When I use the following call :
> Path rootPath = PathFactoryImpl.getInstance().create("{mdweb}/");
>
> I obtain a Path which should be absolute and normalized, then canonical, as
> it begins by / and contain no . or .., but when I test it with the following
> source code :
>
>        if (rootPath.isCanonical()) {
>            System.out.print("is canonical");
>        }
>
>        if (rootPath.isAbsolute()) {
>            System.out.print("is absolute");
>        }
>
>        if (rootPath.isNormalized()) {
>            System.out.print("is normalized");
>        }
>
> I get the message "is normalized" only. If I don't precise the namespace
> with {mdweb} I get a java.lang.IllegalArgumentException: Invalid Name
> literal exception.

... which is correct, since the expected format of the QName string
representation
is "{ns}local", if you omit the namespace it would be "{}local".

i noticed 2 issues in your example:
1. "{mdweb}/" can't be an absolute path since it doesn't start with
the root element.
   the root element is defined as having the empty ns url and the empty
   local name, i.e. the string representation "{}".
2. the string representation of Path uses '\t' (tab) as delimiter for
the name segments.

please note that PathFactory.create(String) and Path.getString() are
intended for
serializing/deserializing Path objects only. an application would probably want
to use PathResolver instead, e.g.

PathResolver resolver = new ParsingPathResolver(...);
Path absPath = resolver.getQPath("/foo:bar/blah:blah");
Path anotherAbsPath = resolver.getQPath("/a/b/c/d");
Path rootPath = resolver.getQPath("/");
Path relPath = resolver.getQPath("b/c");

cheers
stefan

>
> Does anyone have an idea on that problem ? Did I miss something ?
>
> Thank you,
> Pierre
>

Mime
View raw message