cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giacomo Pati <Giacomo.P...@pwr.ch>
Subject Re: [C2] Matcher concept
Date Sun, 25 Jun 2000 21:14:21 GMT
Donald Ball wrote:
> 
> On Sun, 25 Jun 2000, Giacomo Pati wrote:
> 
> > While I'm considering how a sitemap class may be constructed I've
> > encountered the following problem concerning the java layout of a
> > pipeline.
> >
> > As we have proposed that a matcher implements the interface
> >
> >   public interface CompiledMatcher implements Component {
> >     public Map match(...);
> >   }
> >
> > and also consider the following snipped from a hypothetical sitemap
> >
> > <match type="user-agent" pattern="Mozilla */* *">
> >   <match type="uri" pattern="/my/page/*">
> >     <generator type="parser" src="/my/data/$1.xml/>
> >     ...
> >   </match>
> > </match>
> >
> > Now, what is the $1 representing. The browser match or the uri match?
> > Should the pipeline code provide the Map to the matcher so that they
> > could add stuff to it? And then, must a pipeline maintainer count all
> > wildcards from the topmost matcher in the pipeline to get the right
> > replacement, so that in my example the $1 should be written as $4?
> 
> perl would say that the $number convenience variables are reset after the
> next regexp with variables, so you'd need to explicitly save them if you
> need to use them later:
> 
>  <match type="user-agent" pattern="Mozilla */* *">
>    <variable name="agent" value="$1"/>
>    <match type="uri" pattern="/my/page/*">
>      <generator type="parser" src="/my/data/$variable.xml/>
>      ...
>    </match>
>  </match>
> 
> i think that's probably reasonable.

Yes.

> 
> perl also says, though, that wildcarding by itself doesn't save a
> variable - you use parentheses to indicate portions of the regexp to save,
> e.g.:
> 
>  <match type="user-agent" pattern="Mozilla ([^/]+)/* *">

We never said we can mix wildcards and regexp! So you example should be
written like:

  <match type="user-agent" pattern="Mozilla ([^/]+)/([^/]*) ([^/]*)">

because wildcards don't need parenthesis.

Giacomo

-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1 856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1 856 2201
Hintereichenstrasse 7                     Mailto:Giacomo.Pati@pwr.ch
CH-8166 Niederweningen                    Web:   http://www.pwr.ch

Mime
View raw message