You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sebastian Klamar <se...@tux.wh17.tu-dresden.de> on 2004/01/10 18:49:44 UTC

sitemap logic depending on pipeline content

Selectors do only examine the environment (request, session etc.).
I need logic in my pipeline that is depending on the pipeline content
(the current xml that flows through the pipeline).  So I need a bridge
between sitemap logic (selector, matcher, action) and content logic
(transformer).  AFAIK there is nothing Cocoon already offers.

My first thought was to write a transformer myexaminer (because only
transformer have access to the pipeline content) that writes a variable
foo to session or temporary context.  The variable is evaluated by a
selector that can select the next sitemap component for processing.  It
would look like this:

<map:transformer type="bla"/>
<!-- here the session attribute is generated -->
<map:transformer type="myexaminer"/>
<map:select type="session-attribute">
  <map:parameter name="attribute-name" value="foo"/>
  <map:when test="okay">
    <map:transform type="bar"/>
  <map:otherwise>
    <map:transform type="bar2"/>
  <map:otherwise>
<map:select>

Problem: When is the session attribute evaluated when constructing the
pipeline?  Is it done after myexaminer (no problem) or at the beginning
of the pipeline (problem bc it is before myexaminer)?

Uncaredly my theoretical problem, do you have another solution?


TIA -- Sebastian

-- 
Dinge, die man nicht hören will, wenn man operiert wird:
                      »Nun Leute, das wird ein Experiment für uns alle.«
************************************************************************
PGP Key: 0x1E727CE6 / 9085 48BD 8332 4BFC D80C  A6CF D162 20BB 1E72 7CE6

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Why a Selector is evaluated at beginning of pipeline?

Posted by Sebastian Klamar <se...@tux.wh17.tu-dresden.de>.
Geoff, thanx for your answer.

* Geoff Howard [2004-01-12 03:56 +0100] wrote:
> pipeline generator->transormer->serializer is generally thought of
> like the "model" and "view" of the well known "MVC" pattern and
> therefore are not designed to be used as a "controller".  You have
> matchers, selectors, flow and actions for that.

But the controller, say matchers, selectors, flow and
actions, all they have no access to the model (except the new
PipelineUtil.processTo{DOM,SAX})!  So how to achieve control of flow?

This border results in workarounds like using xinclude to call the
next pipeline step (see Conal's first mail in the father thread) or
my currently preferred way: after the examination in a transformer, I
store the result via WriteDOMSessionTransformer, evaluate the status
in my flow script and afterwards call the next pipeline (using the
SessionAttributeGenerator).  This leads to a fragmentation of the
pipeline (as in my example) to 3 pipelines (one for processing till
evaluation, the other two for the map:when and map:otherwise) :-(  IMO
this is not a good solution.  You are right, flow script is destined
for controlling the flow, but I find my »wish example« better because
it better shows flow of data compared with the fragmentation into 3++
pipelines and using session attributes (or the new xmodule).


      Sebastian

-- 
Die letzten Worte...
  des Ehemannes: "Ok!" (Auf die Frage: reparierst Du mal das Bügeleisen,
                                                               Schatzi?)
************************************************************************
PGP Key: 0x1E727CE6 / 9085 48BD 8332 4BFC D80C  A6CF D162 20BB 1E72 7CE6

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Why a Selector is evaluated at beginning of pipeline?

Posted by Geoff Howard <co...@leverageweb.com>.
Sebastian Klamar wrote:
> * Sebastian Klamar [2004-01-10 18:49 +0100] wrote:
> 
>><map:transformer type="bla"/>
>><!-- here the session attribute is generated -->
>><map:transformer type="myexaminer"/>
>><map:select type="session-attribute">
>>  <map:parameter name="attribute-name" value="foo"/>
>>  <map:when test="okay">
>>    <map:transform type="bar"/>
>>  <map:otherwise>
>>    <map:transform type="bar2"/>
>>  <map:otherwise>
>><map:select>
> 
> 
> Given my example, is it right that the selector is evaluated at the
> beginning of the pipeline (after the match when the pipeline is
> constructed), that means BEFORE bla and myexaminor transformer?  Why
> that?

Yes, first any matchers/selectors (they can be infinitely nested) are 
"executed" or better "evaluated", then the 
Generator->Transformer*->Serializer pipeline begins processing.  So, 
your session attribute selector cannot rely on any side effects of the 
generator and transformers which preceed it when reading the sitemap.  I 
think I've already given the answers about why but once again, a 
pipeline generator->transormer->serializer is generally thought of like 
the "model" and "view" of the well known "MVC" pattern and therefore are 
not designed to be used as a "controller".  You have matchers, 
selectors, flow and actions for that.

Geoff


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Why a Selector is evaluated at beginning of pipeline? (was: sitemap logic depending on pipeline content)

Posted by Sebastian Klamar <se...@tux.wh17.tu-dresden.de>.
* Sebastian Klamar [2004-01-10 18:49 +0100] wrote:
> <map:transformer type="bla"/>
> <!-- here the session attribute is generated -->
> <map:transformer type="myexaminer"/>
> <map:select type="session-attribute">
>   <map:parameter name="attribute-name" value="foo"/>
>   <map:when test="okay">
>     <map:transform type="bar"/>
>   <map:otherwise>
>     <map:transform type="bar2"/>
>   <map:otherwise>
> <map:select>

Given my example, is it right that the selector is evaluated at the
beginning of the pipeline (after the match when the pipeline is
constructed), that means BEFORE bla and myexaminor transformer?  Why
that?


TIA -- Sebastian

-- 
Die letzten Worte...
                            des Pilzsammlers: "Diese Art ist mir neu..."
************************************************************************
PGP Key: 0x1E727CE6 / 9085 48BD 8332 4BFC D80C  A6CF D162 20BB 1E72 7CE6

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: sitemap logic depending on pipeline content

Posted by Conal Tuohy <co...@paradise.net.nz>.
Sebastian, you can use the Xinclude or Cinclude transformers for this
purpose: you first use a pipeline that examines your content and emits
either <xi:include href="cocoon:/foo"/> or <xi:include href="cocoon:/baz"/>
and then apply the inclusion which will call either a foo or baz pipeline.

Cheers

Con

> -----Original Message-----
> From: Sebastian Klamar
> [mailto:sebi+lists.cocoon-users@tux.wh17.tu-dresden.de]
> Sent: Sunday, 11 January 2004 06:50
> To: Cocoon User Mailinglist
> Subject: sitemap logic depending on pipeline content
>
>
> Selectors do only examine the environment (request, session etc.).
> I need logic in my pipeline that is depending on the pipeline content
> (the current xml that flows through the pipeline).  So I need a bridge
> between sitemap logic (selector, matcher, action) and content logic
> (transformer).  AFAIK there is nothing Cocoon already offers.
>
> My first thought was to write a transformer myexaminer (because only
> transformer have access to the pipeline content) that writes
> a variable
> foo to session or temporary context.  The variable is evaluated by a
> selector that can select the next sitemap component for
> processing.  It
> would look like this:
>
> <map:transformer type="bla"/>
> <!-- here the session attribute is generated -->
> <map:transformer type="myexaminer"/>
> <map:select type="session-attribute">
>   <map:parameter name="attribute-name" value="foo"/>
>   <map:when test="okay">
>     <map:transform type="bar"/>
>   <map:otherwise>
>     <map:transform type="bar2"/>
>   <map:otherwise>
> <map:select>
>
> Problem: When is the session attribute evaluated when constructing the
> pipeline?  Is it done after myexaminer (no problem) or at the
> beginning
> of the pipeline (problem bc it is before myexaminer)?
>
> Uncaredly my theoretical problem, do you have another solution?
>
>
> TIA -- Sebastian
>
> --
> Dinge, die man nicht hören will, wenn man operiert wird:
>                       »Nun Leute, das wird ein Experiment für
> uns alle.«
> **************************************************************
> **********
> PGP Key: 0x1E727CE6 / 9085 48BD 8332 4BFC D80C  A6CF D162
> 20BB 1E72 7CE6
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org