cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ross Burton" <>
Subject [C2] RT on Patterns and Choosers
Date Mon, 19 Jun 2000 07:11:02 GMT

This is just a quick mail  - I'm going on holiday in an hour - but I was
thinking last night about the choosers and wouold like to say what I

Let's use the infamous regexp example:

1  <choose type="uri">
2  <when test="/\([0-9]\{4\}\)/\([0-9]\{2\}\)/\([0-9]\{2\}\)/">
3      <set-parameter name="year" value="$1"/>
4      <set-parameter name="month" value="$2"/>
5      <set-parameter name="day" value="$3"/>
6      <generator name="serverpages" src="/$(year)/dailynews.xsp"/>
7      <filter name="xslt">
8          <parameter name="stylesheet" value="page2html.xsl"/>
9      </filter>
10  <serializer type="html"/>
11  </when>
12  </choose>

As I have not though about the details behind the chooser implementation,
I'll start at <when test="..."/> on line 2.  Given the URL /2000/06/19 it
succeeds, and returns to Cocoon a String array matches[], containing the
matched elements.  In keeping with regexp tradition, the [0] contains the
entire URL, [1] contains "2000", [2] contains "06" and [3] contains "19".
Next Cocoon processes the set-parameter tags on lines 3 - 5.  These lookup
the values in matchers[], creating parameters in the Request object for
access by any other component in the pipeline (XSLT filters, XSP etc).  The
generator is then invoked, after parsing the src value to replace $(year)
with "2000" from the Request.  That line could have been written <generator
name="serverpages" src="/$1/dailynews.xsp"/> with the same result - with $1
taken from matchers[].  The XSP code can use the parameters year, month and
day from the Request object to retreive data instead of parsing the URL
again.  Next the filter and serializer are invoked.

I think that is how I see this part of the pipeline working - I don't think
there are any holes and that it can generale to any example, although I did
work on it with this example.

Well, have a good time people, I'm off on holiday!

Ross Burton

View raw message