cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Rosman <fluffyl...@gmail.com>
Subject Non matching wildcards and backreferences not mapping to environment properly (2.2)
Date Mon, 21 Sep 2009 02:24:22 GMT
I'm trying to get path components in a URL of the form
http://host:port/application/var1/var2/var3/ to map to URL parameters.

I need the position in the URL to be consistent even if there is
nothing in that position (otherwise the path component gets mapped to
the wrong parameter).

e.g. http://host:port/application/part/var1/var2 gets forwarded to
cocoon:/part?p1=var1&p2=var2

Here's the sitemap bit I thought would work...

<map:match type="regexp"
pattern="part/([^/]*)/?([^/]*)/?([^/]*)/?([^/]*)/?([^/]*)/?">
    <map:redirect-to uri="cocoon:/part?p1={1}&p2={2}&p3={3}&p4={4}&p5={5}"/>
</map:match>
<map:match pattern="part">
    <map:generate type="request"/>
    ...
</map>

The problem is when one of the variables is empty.

e.g. http://host:port/application/part//var2 which should go to
cocoon:/part?var1=&var2=var2 but instead goes to cocoon:/part?var1=p2

It appears that the Matcher doesn't set the properties in the
environment map (which I haven't been able to find any documentation
on to say how it *should* behave) as you would expect a regular
expression to do - i.e. a capturing group which matches an empty
string does not make it into the map and therefore stuffs up the
(index) numbering of matches.

This happens with the wildcard matcher too.

I've tried using named capturing groups
(http://www.regular-expressions.info/named.html) but that doesn't
work.

Places I have looked for answers (so you don't think I'm being slack
and crowd-sourcing my problems :-):
- Google (cocoon mailing lists)
- apache JIRA
- cocoon wiki
- cocoon site

My questions are:
- Has anyone else come across this?
- Is there another reason I'm seeing this and my analysis of it is wrong?
- Would you say this is a bug?
- Is there some minor tweak I can make to get it to work?
- Where should the documentation about this go?

Thanks in advance for any help.

-- 
Stephen Rosman

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message