cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Mazzocchi <stef...@apache.org>
Subject Re: [C2] Matcher concept
Date Sun, 25 Jun 2000 20:41:23 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.
> 
> 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 ([^/]+)/* *">
>   ...
>  </match>

Well, in case you didn't notice there is this example in the current
working draft

 <!--
     Complex example to show how some xpath-like syntax is used 
     to get access to the pattern tokens generated by the matchers.
   -->
 <map:match pattern="nested-matchers/*">
  <map:match type="browser" pattern="name('Mozilla ?\?*')">
   <map:mount src="file:///home/www/mozilla-{1}-{2}/{../1}"/>
  </map:match>
 </map:match>

in which I used XSLT/XPath design principles.

Isn't this good enough?

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<stefano@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



Mime
View raw message