On Sun, Aug 24, 2008 at 12:10 AM, Luca Morandini <[EMAIL PROTECTED]>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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
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.