You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Mika Fonsen <mf...@yahoo.com> on 2003/10/27 14:55:00 UTC
Request attributes from XSP and input modules
Hi,
I'm trying to pass a string as request attribute from an XSP to a
XSLT-stylesheet using an input module. The case #1 works fine.
However, in case #2 if I put an XSLT-transformer in between and try to
read the attribute using an input module, nothing gets trough.
What could be the problem?
Ultimately I'm trying to use the string in an mod-db action, but I left
that part out because of the complexity. I'm actually preprocessing the
post-parameters from a browser before the mod-db action, would there be
a better way doing this?
CASE #1:
--------
SITEMAP.XMAP:
<map:match pattern="test">
<map:generate src="at-test.xsp" type="serverpages"/>
<map:serialize/>
</map:match>
AT-TEST.XSP:
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0">
<root>
<xsp:logic>
String body = "test string";
request.setAttribute("body",body);
</xsp:logic>
<xsp:expr>request.getAttribute("body")</xsp:expr>
</root>
</xsp:page>
CASE #2:
--------
SITEMAP.XMAP (modified):
<map:match pattern="test">
<map:generate src="at-test.xsp" type="serverpages"/>
<map:transform src="paramtest.xsl">
<map:parameter name="param" value="{request-attr:body}"/>
</map:transform>
<map:serialize/>
</map:match>
PARAMTEST.XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="param"/>
<xsl:template match="/">
param:<xsl:value-of select="$param"/>
</xsl:template>
</xsl:stylesheet>
---
Mika Fons�n * http://iki.fi/mf/
__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Request attributes from XSP and input modules
Posted by Christian Haul <ha...@informatik.tu-darmstadt.de>.
Mika Fonsen wrote:
> Hi,
>
> I'm trying to pass a string as request attribute from an XSP to a
> XSLT-stylesheet using an input module. The case #1 works fine.
>
> However, in case #2 if I put an XSLT-transformer in between and try to
> read the attribute using an input module, nothing gets trough.
>
> What could be the problem?
This is a timing problem and sort of a FAQ. So, please search the list
for an in depth explanation. In short, pipeline setup happen *before*
pipeline execution IOW when you pass the parameter to the setup method
of your transformer, the generator (the XSP) hasn't been executed and
thus the parameter is not set, yet.
> Ultimately I'm trying to use the string in an mod-db action, but I left
> that part out because of the complexity. I'm actually preprocessing the
> post-parameters from a browser before the mod-db action, would there be
> a better way doing this?
This would not work as -- again -- the action is run before the XSP is
selected. You may write an XSP-action (or Java action) for this or a
custom input module. Maybe you can achieve the desired effect by
combining several modules...
You may want to consider flow.
Chris.
--
C h r i s t i a n H a u l
haul@informatik.tu-darmstadt.de
fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org