cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <>
Subject Re: [C2] Matcher concept
Date Sun, 25 Jun 2000 18:42:27 GMT
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/>

i think that's probably reasonable.

perl also says, though, that wildcarding by itself doesn't save a
variable - you use parentheses to indicate portions of the regexp to save,

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

- donald

View raw message