cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig Christophersen" <crai...@synesis7.com>
Subject Re: Select the pipeline to execute from an Action
Date Mon, 24 Apr 2006 23:48:21 GMT
Andrew, thank you for the reply.
I believe I have made a solution.
I have created a new Action that gets my data(I get the xml as a string),
then call a class where I check the data to see  which of the determining
elements are present in order to proces differently(there is only one(and
always one).  I save the main data as a session attribute to use with the
appropriate generator in the redirect.
I then am using a selector in the sitemap to redirect to the appropriate
pipeline.  I have just tested the selector functioning properly....each
redirect-to will eventually be a full pipeline with generator, transformer,
etc. rather than a static file.
Sitemap pipeline below:
<map:match pattern="dataModules">

<map:act type="type_action">

<map:select type="parameter">

<map:parameter name="parameter-selector-test" value="{dmType}"/>

<map:when test="descriptive">

<map:redirect-to uri="paraBookmarkPg.html"/>

</map:when>

<map:when test="procedural">

<map:redirect-to uri="tpdrSubmitted.html"/>

</map:when>

<map:when test="fault">

<map:redirect-to uri="isostpBookmarkPg.html"/>

</map:when>

<map:otherwise/>

</map:select>

</map:act>

</map:match>

Again the above is bare bones, but it is working as a proof of concept and I
will be building accordingly.

----- Original Message -----
From: "Andrew Stevens" <ats37@hotmail.com>
To: <users@cocoon.apache.org>
Sent: Monday, April 24, 2006 5:23 PM
Subject: RE: Select the pipeline to execute from an Action


> >From: "Craig Christophersen" <craigch@synesis7.com>
> >Date: Mon, 24 Apr 2006 13:12:59 -0600
> >
> >I need to conditionally execute one of several possible pipelines. I need
> >to do some if/else in an Action on the xml data(probably using a SAX
class)
> >and execute the appropriate pipeline depending upon the data.  I cannot
> >know at the time of the request what pipe line to execute.  Any help in
> >examples or direction on this woule be appreciated.
>
> I suspect you'll struggle, or at least end up with a kludgy workaround.
> Actions and selectors are evaluated during sitemap construcion; the xml
> stream doesn't start flowing through the pipeline until after it's been
> built, so you can't use its contents to decide what building blocks to
> include.  Perhaps you could be a bit more specific as to what you're
trying
> to do?  It may be that there's a different way to approach the problem
that
> doesn't need to do this.
> Anyhow, a few possibilities for workarounds that spring to mind (haven't
> actually tried them all, so don't blame me if they don't work!)
> - Use an XSL transformation that uses xsl:if or xsl:choose to selectively
> c/xinclude from other pipelines (possibly based on the same generator).
> - Much the same, but using the writeDOMsession transformer and
> readDOMsession transformer (or sessionattribute generator?) to avoid
having
> to run the generator again.
> - It should be okay for an action to run another pipeline, and test the
DOM
> produced when that is serialised to decide the action's result.  The
> CopySourceAction can write the contents of its src out to a file, so I
don't
> see why you couldn't parse it instead and evaluate some xpath against it.
> If you don't mind risking some recursion (mmm... OutOfMemoryErrors...) it
> may be possible for the "other" pipeline to be the same one that contains
> the action, but using a view to cut it short before the action.
> - Aggregate all the possible pipelines (with the same initial parts, so
> ideally using the cache to avoid running them multiple times), then use
XSL
> to filter out only one of the branches.  Performance probably isn't so
good
> due to running all the pipelines...
> - I have a vague recollection of some talk on the lists a few months back
> about a dynamic tree builder, that could construct pipelines using a
> dynamically generated sitemap.  Can't remember if that was an existing
> component or just a proposal, though.  Check the archives.
> Or maybe I just dreamed that last one, which wouldn't surprise me given
the
> late hour here.  I'd better stop before I fall asleep at the keyboard :-)
>
>
> Andrew.
>
>
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message