You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Dirk Gronert <u1...@hs-harz.de> on 2004/06/25 16:01:22 UTC
Re: replacing query string parameters in a document
Hello,
it possible to use the VelocityGenerator
(http://cocoon.apache.org/2.1/userdocs/flow/velocity.html). The docu
says, that the objects request,response,session,context and parameters
are always available.
I think: try it out!
Dirk
Rui Alberto L. Gonçalves wrote:
> Hi all,
> I need to replace values that come from the request in
> a xml document.
>
> example:
> My inicial document looks like:
> <doc>
> <user login="$login">
> <email>$email</email>
> ...
> </user>
>
> The URL is: some-url?login=rui&email=rui@some.location.pt
>
> The result should look like:
>
> <user login="rui">
> <email>rui@some.location.pt</email>
> ...
> </user>
>
> I know that can be achieved using a stylesheet... does someone
> knows or would like to suggest a better approach?
>
> Thanks ..
>
> Rui
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: replacing query string parameters in a document
Posted by Peter Velychko <v_...@ukr.net>.
Hello Dirk,
There are some ways to do this. Some of them are:
1. Using XSLT (as mentioned Rui Alberto L.)
I shoult have the stylesheet
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="email" select="'default_email'"/>
<xsl:param name="login" select="'default_login'"/>
<xsl:template match="/">
<user login="{$login}">
<email><xsl:value-of select="$email"/></email>
</user>
</xsl:template>
</xsl:stylesheet>
And in sitemap
<map:match ...>
...
<map:transform type="xslt" src="path/to/your/stylesheet.xsl">
<map:parameter name="use-request-parameters" value="true"/>
</map:transform>
...
</map:match>
2. Using Velocity generator as describes Dirk Gronert
3. Using JXTemplate generaror
For this create template as following JX template (eg that is named
"template.jx")
<?xml version="1.0" encoding="UTF-8"?>
<jx:template xmlns:jx = "http://apache.org/cocoon/templates/jx/1.0">
<user login="${cocoon.request.getParameter('login')}">
<email>${cocoon.request.getParameter('email')}</email>
</user>
</jx:template>
In sitemap
<map:match pattern="test.view">
<map:generate type="jx" src="your/template.jx">
<map:serialize type="xml"/>
</map:match>
...
<map:match pattern="test.html">
<map:call function="testPage"/>
</map:match>
And in flowscript
function testPage() {
cocoon.sendPage("test.view", {});
}
4. Using JXTemplate transformer
The one difference from variant 3 is first part of sitemap snippet
<map:match pattern="test.view">
<map:generate type="file" src="your/template.jx">
<map:transform type="jx">
<map:serialize type="xml"/>
</map:match>
5. Using XSP
Create XSP file ("serverpage.xsp")
<?xml version="1.0" encoding="UTF-8"?>
<xsp:page xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0">
<user>
<xsp:attribute name="login"><xsp-request:get-parameter
name="login"/></xsp:attribute>
<email><xsp-request:get-parameter name="email"/></email>
</user>
</xsp:page>
Place in sitemap
<map:match pattern="test.html">
<map:generate type="serverpages" src="serverpage.xsp"/>
<map:serialize type="xml"/>
</map:match>
Friday, June 25, 2004, 5:01:22 PM, you wrote:
> Hello,
> it possible to use the VelocityGenerator
> (http://cocoon.apache.org/2.1/userdocs/flow/velocity.html). The docu
> says, that the objects request,response,session,context and parameters
> are always available.
> I think: try it out!
> Dirk
> Rui Alberto L. Gonçalves wrote:
>> Hi all,
>> I need to replace values that come from the request in
>> a xml document.
>>
>> example:
>> My inicial document looks like:
>> <doc>
>> <user login="$login">
>> <email>$email</email>
>> ...
>> </user>
>>
>> The URL is: some-url?login=rui&email=rui@some.location.pt
>>
>> The result should look like:
>>
>> <user login="rui">
>> <email>rui@some.location.pt</email>
>> ...
>> </user>
>>
>> I know that can be achieved using a stylesheet... does someone
>> knows or would like to suggest a better approach?
>>
>> Thanks ..
>>
>> Rui
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
--
Best regards,
Peter Velychko
v_peter@ukr.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org