Hi,

For the query engine, I will need a "validate and normalize path" function
that verifies a path is syntactically correct, and simplifies it if
possible, for example:

/a/./b => /a/b
/a/../b => /b

a/.. => .
./a => a
. => 
a/. => a
/.. => invalid
.. => ..
/./. => /

This will not solve the case where a relative path starts with ".."
(possibly multiple levels). I'm wondering if that would be the only
remaining case (a normalize path would never contain "current path", plus
"parent" would always be at the beginning).

Regards,
Thomas


On 11/21/12 9:29 AM, "Angela Schreiber" <[email protected]> wrote:

>hi michael
>
>> +        TreeLocation loc = getLocation();
>> +        for (String element : PathUtils.elements(relPath)) {
>> +            if (PathUtils.denotesParent(element)) {
>> +                loc = loc.getParent();
>> +            } else if (!PathUtils.denotesCurrent(element)) {
>> +                loc = loc.getChild(element);
>> +            }  // else . ->  skip to next element
>> +        }
>> +        return loc;
>
>this is exactly the reason why i was asking for having that
>included in TreeLocation and Tree... we keep adding the exact
>same code everywhere and i am quite sure that you didn't
>cover all usages of relativePath defined by JCR API by this
>fix.
>
>this really looks troublesome and hacky to me.
>
>kind regards
>angela

Reply via email to