cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giacomo Pati <pati_giac...@yahoo.com>
Subject Re: sitemap draft still needs work in the matcher/chooser area
Date Mon, 19 Jun 2000 15:03:46 GMT

--- Stefano Mazzocchi <stefano@apache.org> wrote:
> Donald Ball wrote:
> > 
> > On Sun, 18 Jun 2000, Stefano Mazzocchi wrote:
> > 
> > hmm. not sure if i made myself clear. okay, suppose we have a chooser
> > which relies on a resource from the filesystem - call it the FoobarChooser
> > to avoid any more fights about doing user auth. i want to have the chooser
> > use two different files in different parts of the map. we don't have a
> > syntax for that right now. how about this:
> > 
> > <choosers>
> >  <chooser type="foobar" src:class="org.apache.cocoon.tester.FoobarChooser">
> >   <param name="src" value="/usr/local/etc/foobar.xml"/>
> >  </chooser>
> > </choosers>
> > 
> > <pipeline>
> >  <choose type="foobar">
> >   <param name="src" value="/home/balld/etc/foobar.xml"/>
> >   <when test="foobar('bat')">
> >    <generator/>
> >    <serializer/>
> >   </when>
> >   <otherwise>
> >    ...
> >   </otherwise>
> >  </choose>
> > </pipeline>
> > 
> > that covers the multiple configuration problem. now suppose i wanted to
> > use a relative path in the src parameter - what would it be relative to?
> > the sitemap in which the param element appears? could we use xml:base?
> 
> Good point.... sheesh, the loader namespace doesn't work "inside
> attributes"... should we get back to URL encoding instead?

I've mentioned to Donald in a private mail.
I would suggest to restrict static configuration data (data that doesn't change from request
to
request) to the sitemap component declaration section. It can be of a performance benefit
if
configuration of static data can occur at instantiation time of the components. And as far
as I
see there is nothing that stops us using multiple instances of the same chooser. A sample:

<sitemap>
 <components>
  <chooser type="foobar" src:class="org.apache.cocoon.chooser.FoobarChooser">
   <parameter name="src" value="/usr/local/etc/foobar.xml"/>
  </chooser>
  <chooser type="barbaz" src:class="org.apache.cocoon.chooser.FoobarChooser"/>
   <parameter name="src" value="/home/balld/etc/foobar.xml"/>
  </chooser>
 </components>
 <pipeline>
  <choose type="foobar">
   <when test="foobar('bat')">
    <generator/>
    <serializer/>
   </when>
   <otherwise>
     ...
   </otherwise>
  </choose>
  <choose type="barbaz">
   <when test="foobar('baz')">
    <generator/>
    <serializer/>
   </when>
   <otherwise>
     ...
   </otherwise>
  </choose>
 </pipeline>
</sitemap>

What do you think of this?

> sheesh, the loader namespace doesn't work "inside
> attributes"... should we get back to URL encoding instead?

What do you mean with "doesn't work inside attributes"?

> > > then you have
> > >
> > >  public class URIChooser implements Chooser {
> > >   Map default(CocoonRequest request, String test) {
> > >     // perform wildcard matching filling the map with matched tokens
> > >     if (matched)
> > >      return tokenMap;
> > >     else
> > >      return null;
> > >   }
> > >
> > >   Map regexp(CocoonRequest request, String test) {
> > >     // perform regexp matching filling the map with matched tokens
> > >     if (matched)
> > >      return tokenMap;
> > >     else
> > >      return null;
> > >   }
> > >  }
> > 
> > I'm afraid I don't get the Map thing. How would it work for a simple
> > boolean test like FoobarChooser does?
> 
>   final static public Map true = new MapImpl();
>   final static public Map false = null;
> 
>   if (matched)
>    return true;
>   else
>    return false;
> 
> Admittedly not super-elegant, but how do we do tests and pass tokens to
> the pipeline?

Uh, would you introduce thread-savety issues? 

> Should we peparate "choosers" and "param tokenizers"?

I've seen in the code that now we have the process tag (which is the uri-chooser) which translates
uris to sources using a PatternMatcher because uri and source are available to the process
tag.
What we need now is a object that can be passed along the pipeline components to put information
into it (ie. choosers) or can be queried for information (ie. generators to resolve the source
attribute) because the uri and the source attributes are spread on different tags. 

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

__________________________________________________
Do You Yahoo!?
Send instant messages with Yahoo! Messenger.
http://im.yahoo.com/

Mime
View raw message