You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ron Van den Branden <ro...@kantl.be> on 2007/02/08 15:01:12 UTC
aggregating duplicate parameters at sitemap level
Hi,
In my application, I have some HTML forms containing lists of checkbox
inputs and multiple select boxes. This results in request URIs featuring
duplicate parameter names:
e.g.:
http://localhost:8888/myapp/processform.htm?par1=val1&par1=val2&par1=val3
If I pass these to my XSLT transformation using <map:parameter
name="use-request-parameters" value="true"/>, only the first value (viz.
"val1") ends up in my XSLT. This is a short sitemap.xmap snippet:
<map:match pattern="processform.htm">
<map:generate src="xml/{1}.xml"/>
<map:transform src="stylesheets/xml2htm/{1}.xsl">
<map:parameter name="use-request-parameters" value="true"/>
</map:transform>
<map:serialize type="xhtml"/>
</map:match>
So far, I worked around this with client-side Javascript that would
aggregate those values for the duplicate parameters into one string, so
that only 1 "par1" parameter is passed through:
e.g.: http://localhost:8888/myapp/processform.htm?par1=val1%20val2%20val3
In revising my app (and bringing it closer to unobtrusive JS practice),
however, I would like to free that vital part of its fuctionality (form
submission) from this client-side Javascript dependency.
My question is: is there a way of aggregating duplicate parameters into
one parameter at sitemap level? The scarce posts I came across on this
list suggest that it *can* be done (e.g.
http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=113474098814411&w=2),
but not exactly how... At least, I can't see a solution with my current
cocoon knowledge (not much beyond simple pipeline concepts, ie. no
flowscript, actions, XSP...).
I recognize this is not strictly a Cocoon problem (and apologize for
off-topicality), but hope there may be a Cocoon solution?
Thanks for any reaction!
Ron Van den Branden
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: aggregating duplicate parameters at sitemap level
Posted by Jeroen Reijn <j....@hippo.nl>.
Hi Ron,
Ron Van den Branden wrote:
> Hi Jeroen,
>
> Thanks a lot for this quick and helpful hint: I now manage to get an XML
> representation of the request with the RequestGenerator. That's
> excellent for XSL processing, but... I still don't see clearly how I can
> integrate this in the pipeline (sorry - I take full account of my
> ignorance).
No problem. I had to learn all of this myself too! :-) Well since the
all request parameters are in the generator, you will not have to pass
them to the transformer, since you already have them.
>
> Jeroen Reijn schreef:
>>
>>
>> In that case the only thing you need to do in your sitemap is change
>> your generate part to an aggregate and you will probably have to
>> change your xslt a bit and that would be it.
>>
> Do I understand you correctly by thinking that you'd aggregate both the
> XML request representation (via RequestGenerator) and the requested XML
> source (via another pipeline) into an XML structure for further
> processing? Something like:
>
> <map:match pattern="processform.htm">
> <map:aggregate>
> <!-- get XML representation of request -->
> <map:part src="???"/>
> <!-- get XML source -->
> <map:part src="???"/>
> </map:aggregate>
> <map:transform src="stylesheets/xml2htm/{1}.xsl">
> <map:parameter name="use-request-parameters" value="true"/>
> </map:transform>
> <map:serialize type="xhtml"/>
> </map:match>
>
> Then the question marks are unclear to me...
You are correct with the above. The aggregate should in your case look like:
<map:aggregate element="root">
<!-- get XML representation of request -->
<map:part src="cocoon:/requestAsXML"/>
<!-- get XML source -->
<map:part src="xml/{1}.xml"/>
</map:aggregate>
As you might have noticed the first part calls another pipeline which
generates the request. That should be:
<map:match pattern="requestAsXML">
<map:generate type="request"/>
<map:serialize type="xml"/>
</map:match>
Now you will have to change your xslt to handle the extra wrapping
element and that should be it.
>
>> Just as a side note: I always discourage use-request-parameters, since
>> it can give you problems when using caching pipelines.
>>
> What alternative do you suggest?
Well it depends on what you want to do within your pipeline, but I
always declare my request parameters separately. Using the
use-request-parameters parameter will make all your request parameters
end up in your cachekey (if your pipeline is set to caching). So if
let's say some crawler runs by your website and the crawler uses a time
stamp as a request parameter, all these request will get a seperate
cachekey. It will enlarge your cache enormously.
>
> Thank you very much,
Your welcome.
>
Jeroen Reijn
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: aggregating duplicate parameters at sitemap level
Posted by Ron Van den Branden <ro...@kantl.be>.
Hi Jeroen,
Thanks a lot for this quick and helpful hint: I now manage to get an XML
representation of the request with the RequestGenerator. That's
excellent for XSL processing, but... I still don't see clearly how I can
integrate this in the pipeline (sorry - I take full account of my
ignorance).
Jeroen Reijn schreef:
>
>
> In that case the only thing you need to do in your sitemap is change
> your generate part to an aggregate and you will probably have to
> change your xslt a bit and that would be it.
>
Do I understand you correctly by thinking that you'd aggregate both the
XML request representation (via RequestGenerator) and the requested XML
source (via another pipeline) into an XML structure for further
processing? Something like:
<map:match pattern="processform.htm">
<map:aggregate>
<!-- get XML representation of request -->
<map:part src="???"/>
<!-- get XML source -->
<map:part src="???"/>
</map:aggregate>
<map:transform src="stylesheets/xml2htm/{1}.xsl">
<map:parameter name="use-request-parameters" value="true"/>
</map:transform>
<map:serialize type="xhtml"/>
</map:match>
Then the question marks are unclear to me...
> Just as a side note: I always discourage use-request-parameters, since
> it can give you problems when using caching pipelines.
>
What alternative do you suggest?
Thank you very much,
Ron Van den Branden
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: aggregating duplicate parameters at sitemap level
Posted by Jeroen Reijn <j....@hippo.nl>.
Hi Ron,
since you want to keep it as simple as possible, you could also take a
look at the RequestGenerator [1]. You can then use your XSL to process
the multiple results.
In that case the only thing you need to do in your sitemap is change
your generate part to an aggregate and you will probably have to change
your xslt a bit and that would be it.
Just as a side note: I always discourage use-request-parameters, since
it can give you problems when using caching pipelines.
Kind regards,
Jeroen Reijn
[1]
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/generation/RequestGenerator.html
Ron Van den Branden wrote:
> Hi,
>
> In my application, I have some HTML forms containing lists of checkbox
> inputs and multiple select boxes. This results in request URIs featuring
> duplicate parameter names:
>
> e.g.:
> http://localhost:8888/myapp/processform.htm?par1=val1&par1=val2&par1=val3
>
> If I pass these to my XSLT transformation using <map:parameter
> name="use-request-parameters" value="true"/>, only the first value (viz.
> "val1") ends up in my XSLT. This is a short sitemap.xmap snippet:
>
> <map:match pattern="processform.htm">
> <map:generate src="xml/{1}.xml"/>
> <map:transform src="stylesheets/xml2htm/{1}.xsl">
> <map:parameter name="use-request-parameters" value="true"/>
> </map:transform>
> <map:serialize type="xhtml"/>
> </map:match>
>
> So far, I worked around this with client-side Javascript that would
> aggregate those values for the duplicate parameters into one string, so
> that only 1 "par1" parameter is passed through:
>
> e.g.: http://localhost:8888/myapp/processform.htm?par1=val1%20val2%20val3
>
> In revising my app (and bringing it closer to unobtrusive JS practice),
> however, I would like to free that vital part of its fuctionality (form
> submission) from this client-side Javascript dependency.
>
> My question is: is there a way of aggregating duplicate parameters into
> one parameter at sitemap level? The scarce posts I came across on this
> list suggest that it *can* be done (e.g.
> http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=113474098814411&w=2),
> but not exactly how... At least, I can't see a solution with my current
> cocoon knowledge (not much beyond simple pipeline concepts, ie. no
> flowscript, actions, XSP...).
>
> I recognize this is not strictly a Cocoon problem (and apologize for
> off-topicality), but hope there may be a Cocoon solution?
>
> Thanks for any reaction!
>
> Ron Van den Branden
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org