cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <joerg.heini...@gmx.de>
Subject Re: order of execution in the pipeline
Date Fri, 04 May 2007 17:09:07 GMT
On 04.05.2007 17:58, Stefan Shoeman wrote:
> Hello Marc,
> 
> thanks for your hints. No, I can't use the standard pdf serializer,
> because I have to create them with a external application.
> 
> I tried to get my custom order with a flowscript. But that doesn't
> work, too. I can't call another process (start the external app with
> my action) _after_ the serialization of the html.
> 
> It's frustrating...

Come on Stefan ;)

You can work with a setup very similar to the one I gave recently at [1] 
for a completely different use case. In contrary to this example your 
setup would be (again 3 pipelines):

// same pattern as before
<map:match pattern="">
    // delegate to a flow script function
    <map:call function="process"/>
</map:match>

// get file, transform it and write it to disk
<map:match pattern="getFile">
    <map:generate/>
    // your transforms
    <map:transform type="write-source"/>
    <map:serialize type="xml"/>
</map:match>

// final processing
<map:match pattern="showHtml">
    <map:act type="MyCustomAction"/>
    // it's probably possible to inject the document directly,
    // otherwise get and transform the file again
    <map:generate/>
    // your transforms
    <map:serialize/>
</map:match>

flow script:

function process() {
    var pipelineUtil = // get pipelineUtil
    var data = // data you might need to retrieve the file
    var document = pipelineUtil.processToDOM("getFile", data);
    cocoon.sendPage("showHtml");
}

This is the easiest conversion possible I think. But having this setup 
you might improve and simplify it by dropping SourceWriteTransformer and 
changing the implementation of MyCustomAction a bit, so that it is no 
longer a Cocoon Action and no longer needs to reparse the file from disk.

1. drop <map:transform type="write-source"/> and <map:act 
type="MyCustomAction"/> completely

2. flow script:
function process() {
    var pipelineUtil = // get pipelineUtil
    var data = // data you might need to retrieve the file
    var document = pipelineUtil.processToDOM("getFile", data);
    var myCustomAction = // get MyCustomAction, either POJO or simple
                         // component independent from sitemap
    myCustomAction.process(document);
    cocoon.sendPage("showHtml");
}

You can also store the DOM on the disk to retrieve it from 
MyCustomAction. That's still better than to clutter the sitemap. 
Furthermore PipelineUtil provides methods to work with DOM, SAX or 
OutputStream, so you can integrate them even more, e.g. by providing a 
SAX ContentHandler.

Hope that gets you the idea.

Joerg

[1] http://marc.info/?l=xml-cocoon-users&m=117784283420555&w=4

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


Mime
View raw message