You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Erasmo <ei...@gmail.com> on 2008/08/24 07:41:52 UTC

Cocoon 3 empty project

Hi everybody.

I'm doing a project for a kind DAM system i'm using the restlet framework
because i want to expose my api via restful web services i choosed atom as
the presentation layer for other to consume it, but later another guy ask me
to provide a minor portion of my data as RSS i realized then that i had to
separate the presentation layer which leads me to create a thin validator
and transformer that validates via schema the incoming Atom request and
transforms it via xslt to the required xml form this layer takes a
stylesheet as an argument and a stream as input for the transformer and a
schema(s) and a stream for the validator.

So why i'm relating all these history? Some one pointed me out that there
was something that is doing exactly the same that i do but in a rather much
more automated and standarized way, that was...you guessed Cocoon. I have
read a few articles and it looks great and promissing what Coocon does so im
actually evaluating if i can migrate the whole job to Coocon and was
whishing if someone in this list could tell me if am i in the right way. My
requirements are:

1.- I should be able to transform incoming request (incoming transform
pipes?).
2.- I should be abe to manage the rest url style.
3.- I should be able to transform outcoming responses based on a
programatically generated way.

Is this possible all this with Coocon?

Thanks all in advance.

Re: Cocoon 3 empty project

Posted by Martin Heiden <ma...@netcologne.de>.
Hi!

Erasmo schrieb:
>  I have read a few articles and it looks great and promissing
> what Coocon does so im actually evaluating if i can migrate the whole 
> job to Coocon and was whishing if someone in this list could tell me if 
> am i in the right way. 

Sure, you can use cocoon to do that. But you've got to learn how cocoon 
works and that will take some time. It's definitely worth learning it, 
but I guess that this is important for your decision.
If you already feel comfortable with the Restlet API, you should also 
consider Kauri as an alternative. Right now it is in a very early stage, 
but it sounds promising.

Take a look at: http://kauriproject.org

Much fun!

Martin

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


Re: Cocoon 3 empty project

Posted by Luca Morandini <lm...@ieee.org>.
Erasmo wrote:
> 
> Luca thanks for your prompt response. Resuming the "incoming 
> transformation" can you provide a map snippet on how to do it? For 
> example a user sends an Atom PUT request with an entry and i want to be 
> able to take that request body transform it to my desired xml and then 
> save that xml to say a DB or anything else, that means i should be able 
> to consume the output of a pipeline internally, perhaps in some action 
> or something? It's this scenario possible, 

I presume that Martin already answered you on this in another thread.


> do you know some tutorial, 
> howto, article or documentation that explains this? I'm reading 
> NewRiders - Cocoon Building XML Applications and Manning Art of Java Web 
> Development but they are pretty old books (2002, 2006) which does not 
> explain the new 2.2 way of Cocoon development.

Look, 2.2 is mostly a change in packaging and components handling (Maven 
and Spring, respectively), but the functionality has remained largely 
unaltered: you can still use most (if not all) of the 2.1 stuff like 
generators, transformers, serializers, flowscript, forms, etc.

Unfortunately, books devoted to Cocoon cover 2.0, not 2.1, stuff, hence 
flowscripts and forms are not to be found in them.

Anyway, once you have you first Coocoon webapp up and running in 2.2, 
you can re-use most of the 2.1 doc and a sizeable portion of the 2.0 one.

Regards,

--------------------
    Luca Morandini
www.lucamorandini.it
--------------------


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


Re: Cocoon 3 empty project

Posted by Erasmo <ei...@gmail.com>.
On Sun, Aug 24, 2008 at 12:10 AM, Luca Morandini <lm...@ieee.org>wrote:

> Erasmo wrote:
>
>> My requirements are:
>>
>> 1.- I should be able to transform incoming request (incoming transform
>> pipes?).
>>
>
> You mean transforming via XSLT ? Yes, you can... you can also send request
> parameters or portion of URIs to XSLT as parameters just by using the
> sitemap:
>
>      <map:match pattern="pages/*.html">
>        <map:generate type="jx" src="contents/{1}.xml"/>
>        <map:transform src="resource/external/page-styling.xsl">
>          <map:parameter name="format" value="{request-param:format}"/>
>          <map:parameter name="page" value="{1}"/>
>        </map:transform>
>        <map:transform type="i18n">
>          <map:parameter name="locale" value="{request-param:locale}"/>
>        </map:transform>
>        <map:serialize type="html"/>
>      </map:match>
>
>
>  2.- I should be abe to manage the rest url style.
>>
>
> Yes, I did some experiments myself and come out with sitemap fragments like
> these:
>
>      <!--
>        Intecepts all URIs starting with "api/" and calls the corresponding
>        Flowscript function based on the HTTP method. Actually, the function
>        name is a concatenation of the last part of the URI and "Set" or
> "Get"
>        depending on the HTTP method.
>      -->
>      <map:match pattern="api/*">
>        <map:select type="request-method">
>          <map:when test="GET">
>            <map:call function="{1}Get"/>
>          </map:when>
>          <map:when test="PUT">
>            <map:call function="{1}Set"/>
>          </map:when>
>        </map:select>
>      </map:match>
>
>      <!--
>        Emits as JSON the obj collection object received from Flowscript.
>      -->
>      <map:match pattern="apipages/send-json">
>        <map:read src="module:flow-attr:json" mime-type="text/javascript"/>
>      </map:match>
>
>      <!--
>        Emits as XML the obj collection object received from Flowscript. URI
>        format is send-{set|map}.xml
>      -->
>      <map:match pattern="apipages/send-*.xml">
>        <map:generate type="jx" src="pages/{1}.jx">
>          <map:parameter name="obj" value="{flow-attr:obj}"/>
>        </map:generate>
>        <map:serialize type="xml"/>
>      </map:match>
>
>
>  3.- I should be able to transform outcoming responses based on a
>> programatically generated way.
>>
>
> Not sure I have understood you on this: requests are transformed into
> responses, why did you split transforming incoming requests from
> transforming outgoing responses ?
>
> Anyway, the same XML may be outputted using different formats by using
> different serializers, since the staged nature of pipelines allows for great
> flexibility.
>
>
>  Is this possible all this with Coocon?
>>
>
> I guess so.
>
> Regards,
>
> --------------------
>   Luca Morandini
> www.lucamorandini.it
> --------------------
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Luca thanks for your prompt response. Resuming the "incoming transformation"
can you provide a map snippet on how to do it? For example a user sends an
Atom PUT request with an entry and i want to be able to take that request
body transform it to my desired xml and then save that xml to say a DB or
anything else, that means i should be able to consume the output of a
pipeline internally, perhaps in some action or something? It's this scenario
possible, do you know some tutorial, howto, article or documentation that
explains this? I'm reading NewRiders - Cocoon Building XML Applications and
Manning Art of Java Web Development but they are pretty old books (2002,
2006) which does not explain the new 2.2 way of Cocoon development.

Re: Cocoon 3 empty project

Posted by Luca Morandini <lm...@ieee.org>.
Erasmo wrote:
> My requirements are:
> 
> 1.- I should be able to transform incoming request (incoming transform 
> pipes?).

You mean transforming via XSLT ? Yes, you can... you can also send 
request parameters or portion of URIs to XSLT as parameters just by 
using the sitemap:

       <map:match pattern="pages/*.html">
         <map:generate type="jx" src="contents/{1}.xml"/>
         <map:transform src="resource/external/page-styling.xsl">
           <map:parameter name="format" value="{request-param:format}"/>
           <map:parameter name="page" value="{1}"/>
         </map:transform>
         <map:transform type="i18n">
           <map:parameter name="locale" value="{request-param:locale}"/>
         </map:transform>
         <map:serialize type="html"/>
       </map:match>


> 2.- I should be abe to manage the rest url style.

Yes, I did some experiments myself and come out with sitemap fragments 
like these:

       <!--
         Intecepts all URIs starting with "api/" and calls the corresponding
         Flowscript function based on the HTTP method. Actually, the 
function
         name is a concatenation of the last part of the URI and "Set" 
or "Get"
         depending on the HTTP method.
       -->
       <map:match pattern="api/*">
         <map:select type="request-method">
           <map:when test="GET">
             <map:call function="{1}Get"/>
           </map:when>
           <map:when test="PUT">
             <map:call function="{1}Set"/>
           </map:when>
         </map:select>
       </map:match>

       <!--
         Emits as JSON the obj collection object received from Flowscript.
       -->
       <map:match pattern="apipages/send-json">
         <map:read src="module:flow-attr:json" mime-type="text/javascript"/>
       </map:match>

       <!--
         Emits as XML the obj collection object received from 
Flowscript. URI
         format is send-{set|map}.xml
       -->
       <map:match pattern="apipages/send-*.xml">
         <map:generate type="jx" src="pages/{1}.jx">
           <map:parameter name="obj" value="{flow-attr:obj}"/>
         </map:generate>
         <map:serialize type="xml"/>
       </map:match>


> 3.- I should be able to transform outcoming responses based on a 
> programatically generated way.

Not sure I have understood you on this: requests are transformed into 
responses, why did you split transforming incoming requests from 
transforming outgoing responses ?

Anyway, the same XML may be outputted using different formats by using 
different serializers, since the staged nature of pipelines allows for 
great flexibility.


> Is this possible all this with Coocon?

I guess so.

Regards,

--------------------
    Luca Morandini
www.lucamorandini.it
--------------------


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