cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vadim Gritsenko" <vgritse...@hns.com>
Subject RE: [C2] Question About WildcardURIMatcher
Date Sat, 26 Aug 2000 00:58:37 GMT
> From: giacomo@hns.com [mailto:giacomo@hns.com]On Behalf Of Giacomo Pati
>
> > Vadim Gritsenko wrote:
> >
> > Hi,
> >
> > Is it OK that '<map:match pattern="welcome">' (from sitemap.xmap)
> > matches http://host/cocoon/welcome as well as
> > http://host/cocoon/zzzzzzwelcomezzzzzzzzz?
> > I mean, it should work this way or this is an error?
>
> Unfotunately it's the way it workes. That's why I have used the
> RegexpURIMatcher to have a way to determine start and end on a pattern
> (see my mail yesterday about this topic).
>
> Maybe you have a way or proposal how to fix it?

Giacomo,
I have got some solution - it is implemented in attached files. Here is the
main changes:

1. I have added two more constants to matcher: MATCH_BEGIN and MATCH_THEEND.
If you will put MATCH_BEGIN in the very beginning of expression array, it
will work like
'^' in regular expresions, and if you put MATCH_THEEND instead of MATCH_END
- you will get behavior of '$'.
2. I changed behavior of '**'. Now it tries to match as more as possible
(instead of
"indexOf", I used "lastIndexOf").
3. WildcardURIMatcherFactory.java now always uses MATCH_BEGIN and
MATCH_THEEND.

If you will not use MATCH_BEGIN and MATCH_THEEND - behavior will be the same
as before,
except '**': now it is possible to write matchers like <map:match
pattern="images/**.*">.

Because of new behavior, I found error in jakarta_apache_org-html.xsl:
instead of
<link rel="stylesheet" href="styles/jakarta_apache_org.css"><!-- no not
remove this comment --></link>
should be
<link rel="stylesheet" href="../styles/jakarta_apache_org.css"><!-- no not
remove this comment --></link>
(directory "sites" in which xml resides was ignored by previous version of
matcher).

Also, as an experiment, I replaced several image matchers (gif, jpeg, png)
with one:
   <map:match pattern="images/**.*">
    <map:read src="resources/images/{1}.{2}" mime-type="image/{2}"/>
   </map:match>

And for files/directories:
   <map:match pattern="**/">
    <map:generate type="directory" src="{1}"/>
    <map:transform src="stylesheets/system/directory2html.xsl"/>
    <map:serialize/>
   </map:match>

   <map:match pattern="**">
    <map:read src="{1}" mime-type="text/plain"/>
   </map:match>
So it can work like "text/plain" web server :)

Also, added patch for slides demo: corrected links to images.

I hope that you will find these changes acceptable.

Sincerely,
Vadim

Mime
View raw message