dominik:

> I'm sorry to bother you, but I can't direcly subscribe to the mail list
> because of my company. you posted on the cocoon list:

No bother....the least I can do is to help out a fellow Cocoon afficionado, 
since I have received a lot of help myself.  Gotta pass on the karma when you 
can. ;-)

However, I will copy this reply to the list, in case anyone else there has a 
similar issue.  This way it will be in the archives for future reference or 
maybe someone will post it on the Cocoon Wiki? (hint...hint.... ;-)  ).

> > Try SourceWritingTransformer from the sitemap or else
> > cocoon.processPipelineTo from a flowscript.

> <I decided to bite the bullet and add flowscript to my app....it worked 
> <perfectly!

> would you please be so kind and give me a short outline of this solution? I'm
> having a similar problem for weeks, but there was nothing is sight.

Sure thing.  Here is what I did (salient parts only...not a full working 
example):

I have a flowscript called "saveToFile.flow" (I call my flowscripts *.flow to 
distinguish them from normal client side javascripts, but you can call them 
*.js if you want), source attached to this email.

In my sitemap, in the <map:components> section I have the following entry:

        <map:flow-interpreters default="JavaScript"/>

Then I include a flow definition later in the sitemap:

        <map:flow language="javascript">
                <map:script src="scripts/saveToFile.flow"/>
        </map:flow>

Which will cause Cocoon to load the flowscript and make it available for 
execution in pipelines. (Note: you may need a pipeline to source the 
scripts/*.flow files using a simple Cocoon reader.  I assume you know enough 
about cocoon to put that in place).

Then I have a pipeline that looks like this, to actually execute the 
flowscript and save the output of a particular pipeline:

<map:pipeline>
        <map:match pattern="saveFile.html">
                <map:call function="saveToFile"/>
                <map:select type="request-attribute">
                        <map:parameter name="attribute-name" 
value="centralPrint.status"/>
                        <map:when test="success">       
                                <!-- Do something useful here, since the saveToFile 
succeeded -->
                                .....
                        </map:when>
                        <map:otherwise>
                                <map:read src="html/saveToFileFailed.html" 
mime-type="text/html"/>
                        </map:otherwise>
                </map:select>
        </map:match>
</map:pipeline>

Then there is a pipeline that generates the actual output that you want to 
save, which in my example, is output.xml.  Note that the flowscript 
saveToFile.flow references output.xml, which is how it initiates execution of 
the following pipeline:

<map:pipeline internal-only="true">
        <map:match pattern="output.xml">
                <map:generate type="file" src="xml/input.xml"/>
                <map:transform src="xsl/myTransform.xsl"/>
                <map:serialize type="xml"/>
        </map:match>
</map:pipeline>

So....when the user accesses a url of the form "saveFile.html", Cocoon will 
execute the first pipeline above, which in turn calls the flowscript, which  
will then fire off the 2nd pipeline, and voila...your file is now saved in a 
temp directory with a unique name!  The filename that was generated for the 
save is returned in a request attribute called saveToFile.tempFile, so you 
can get it later in your pipeline if you need to along with a status 
attribute so you know if it succeeded or not.

Hope this helps!





Andrzej Jan Taramina
Chaeron Corporation: Enterprise System Solutions
http://www.chaeron.com

The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any other MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.

   ---- File information -----------
     File:  saveToFile.flow
     Date:  5 Nov 2003, 11:55
     Size:  1296 bytes.
     Type:  Unknown

Attachment: saveToFile.flow
Description: Binary data

Reply via email to