cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Stevens" <>
Subject RE: Select the pipeline to execute from an Action
Date Mon, 24 Apr 2006 23:23:49 GMT
>From: "Craig Christophersen" <>
>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 :-)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message