You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Norman Barker <no...@comsine.co.uk> on 2004/08/27 15:30:18 UTC

how to use a CInclude template to include resources

Hi,
 
I am rephrasing this to be clearer, thanks Derek.

I have set up several pipelines and readers within cocoon.
I can include XML content without any problems using a CInclude template,
as in the following example (not the real code, just dummy names).

<data xmlns:cinclude="http://apache.org/cocoon/include/1.0">
    <MyCollection1>
        <cinclude:include src="cocoon:/test1" element="data1"/>
    </MyCollection1>
    <MyCollection2>
        <cinclude:include src="cocoon:/test2" element="data2"/>
    </MyCollection2>
</data>

so cocoon:/test1 returns XML and this fits in nicely.

however when I want to include image content within the template I would 
like to
do either of the two things below as in the case of cocoon:/test2 being 
a reader;

1) Save the image returned from the reader in a temporary location that 
is cleaned
by Cocoon after the request and a URL to this resouces is stored in the 
XML (an
example of this would help me alot)

2) store a BaseBinary64 version of this image in the XML, or just the 
pixel values

Finally, is I post an XML document to Cocoon which looks like for example
<root>
   <request1>...</request1>
    <request2>...<request2>
</root>

is there a generator that will iterate over this document and make each 
of the requests, or do
I have to write a custom generator? I don't expect the user to make 
multiple requests to the
server, just to wrap up all the requests in one go and send them to the 
server.  So can I iterate
over this?

Any help would be gratefully appreciated.

Norman

-- 
Norman Barker
Software Engineer
ComSine Ltd
Tel: +44 (0)1483 457121
Web: http://www.comsine.com
*Please Note:*
This text is confidential. If you are not the named addressee, it could be unlawful for you to read, copy, distribute, disclose or use the information contained herewith. If you are not the intended recipient please telephone +44(0)1483 457121.


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


Re: how to use a CInclude template to include resources

Posted by Jorg Heymans <jh...@domek.be>.

Norman Barker wrote:

> Hi,
> 
> I am rephrasing this to be clearer, thanks Derek.
> 
> I have set up several pipelines and readers within cocoon.
> I can include XML content without any problems using a CInclude template,
> as in the following example (not the real code, just dummy names).
> 
> <data xmlns:cinclude="http://apache.org/cocoon/include/1.0">
>    <MyCollection1>
>        <cinclude:include src="cocoon:/test1" element="data1"/>
>    </MyCollection1>
>    <MyCollection2>
>        <cinclude:include src="cocoon:/test2" element="data2"/>
>    </MyCollection2>
> </data>
> 
> so cocoon:/test1 returns XML and this fits in nicely.
> 
> however when I want to include image content within the template I would 
> like to
> do either of the two things below as in the case of cocoon:/test2 being 
> a reader;
> 
> 1) Save the image returned from the reader in a temporary location that 
> is cleaned
> by Cocoon after the request and a URL to this resouces is stored in the 
> XML (an
> example of this would help me alot)
This sounds like something flow could do.
so you cinclude:include src="cocoon:/pipelineWithMyFlowFunction" instead 
of cocoon:/test1.
In this flow function you generate your image and write it to a 
temporary file (using processPipelineTo), you then return your file 
identifier so it gets included in the document.


> 
> 2) store a BaseBinary64 version of this image in the XML, or just the 
> pixel values
modify your reader to spit out base64 seems the easiest thing to do here.

> 
> Finally, is I post an XML document to Cocoon which looks like for example
> <root>
>   <request1>...</request1>
>    <request2>...<request2>
> </root>
> 
> is there a generator that will iterate over this document and make each 
> of the requests, or do
> I have to write a custom generator? I don't expect the user to make 
> multiple requests to the
> server, just to wrap up all the requests in one go and send them to the 
> server.  So can I iterate
> over this?
If this iteration definition needs to come from the outside world then 
you could write an xsl that transforms
<root>
   <req1></req1>
   <req2></req2>
...
into
<mycollection>
   <cinclude:include src="the contents of element req1"/>
   <cinclude:include src=cocoon:/"the contents of element req2"/>
</mycollection>
and then have the cinclude transform do it's work.


HTH
Jorg


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