You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by 32...@gmail.com on 2006/06/23 16:06:57 UTC

Accessing request-param in XML

Hello community,

my sitemap:
<map:match pattern="zipped.zip">
         <map:generate src="zip.xml"/>
            <map:parameter name="pk" value="{request-param:pk}"/>
         <map:serialize type="zip"/>
 </map:match>

my zip.xml
<zip:archive xmlns:zip="http://apache.org/cocoon/zip-archive/1.0">
  <zip:entry name="print.pdf" src="
http://localhost:8080/cocoon/print.pdf?pk=xx">
  </zip:entry>
</zip:archive>


What I want to do:
call the URL http://localhost:8080/cocoon/zipped.zip?pk=45. The request
parameter should be passed to zip.xml and be put into the src URL of my
print.pdf; so that the zip.xml looks in this case like that:
<zip:archive xmlns:zip="http://apache.org/cocoon/zip-archive/1.0">
  <zip:entry name="print.pdf" src="
http://localhost:8080/cocoon/print.pdf?pk=45">
  </zip:entry>
</zip:archive>

(Something like the SQLTransformer '<sql:substitute-value sql:name="pk"/>')
How can I achieve that?

Thanks
Marco

Re: Accessing request-param in XML

Posted by Yves Vindevogel <yv...@implements.be>.
You can start of an XSP instead of an XML
Just make sure that your XSP generates the same XML syntax as you have now.
Then you can use xsp-request to get your param.

Here's some code I use in XSP
<xsp:page language="java"
    xmlns:xsp="http://apache.org/xsp"
    xmlns:xsp-request="http://apache.org/xsp/request/2.0"
    create-session="true">
   
   
    <zip:archive xmlns:zip="http://apache.org/cocoon/zip-archive/1.0">
        <xsp:logic>
            String uri = <xsp-request:get-sitemap-uri/> ;
            String src ;
            String name ;
           
            src = uri.substring(12 , uri.length() - 4) + ".csv" ;
            name = src.substring(5, src.length() - 4) + ".csv" ;
        </xsp:logic>

        <zip:entry>
            <xsp:attribute 
name="name"><xsp:expr>name</xsp:expr></xsp:attribute>
            <xsp:attribute 
name="src">cocoon:/reports/<xsp:expr>src</xsp:expr></xsp:attribute>
        </zip:entry>  
    </zip:archive>


</xsp:page>


http://cocoon.apache.org/2.1/userdocs/logicsheets/request.html

321los@gmail.com wrote:
> Hello community,
>
> my sitemap:
> <map:match pattern="zipped.zip">
>          <map:generate src="zip.xml"/>
>             <map:parameter name="pk" value="{request-param:pk}"/>  
>          <map:serialize type="zip"/>
>  </map:match>
>
> my zip.xml
> <zip:archive xmlns:zip="http://apache.org/cocoon/zip-archive/1.0 
> <http://apache.org/cocoon/zip-archive/1.0>">
>   <zip:entry name="print.pdf" 
> src="http://localhost:8080/cocoon/print.pdf?pk=xx">
>   </zip:entry>
> </zip:archive>
>
>
> What I want to do:
> call the URL http://localhost:8080/cocoon/zipped.zip?pk=45. The 
> request parameter should be passed to zip.xml and be put into the src 
> URL of my print.pdf; so that the zip.xml looks in this case like that:
> <zip:archive xmlns:zip="http://apache.org/cocoon/zip-archive/1.0">
>   <zip:entry name="print.pdf" 
> src="http://localhost:8080/cocoon/print.pdf?pk=45">
>   </zip:entry>
> </zip:archive>
>
> (Something like the SQLTransformer '<sql:substitute-value 
> sql:name="pk"/>')
> How can I achieve that?
>
> Thanks
> Marco

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