Joe D. Williams wrote:

OK. I have done this before, but am confused as to the simplest way to
accomplish a fairly trivial task: Passing a request attribute to the
sitemap.


[snip]

The documentation on the SQLTransformer suggests the following: [snip]

When I first struggled with this example (not so very long ago), someone off list pointed out that the key was the Request generator feeding an XSL transformation which is passed to the SQL transformer.

Warning: The following example was cut and edited from live code but hasn't actually been fully tested.

Assuming a URL like this
   http://my.cocoon.server.ca/search?SearchTerms=Help

<map:match pattern="*/search">
<map:generate type="request"/>
<map:transform src="Search/Search.xsl" />
<map:transform type="sql">
<map:parameter name="use-connection" value="ConnectionName" />
<map:parameter name="show-nr-of-rows" value="true"/>
</map:transform>
<map:transform src="/xsl/SearchtoHTML.xsl">
<map:parameter name="use-request-parameters" value="true"/>
</map:transform>
<map:serialize type="html"/>
</map:match>


The Request generator does not get a lot of play but it will hand off an xml representation of the HTML header to the transformer.

In the XSLT transformation that follows might look something like:

?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0" xmlns:h="http://apache.org/cocoon/request/2.0";>
<xsl:param name="SearchTerms"><xsl:value-of select="//h:[EMAIL PROTECTED]'SearchTerms']/h:value"/></xsl:param>
xsl:template match="/">
<document>
<sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0";>
<sql:query name="Main">
[Your SQL statement with the search parameters <xsl:value-of select="$SearchTerms"/> substituted in the appropriate place]
</sql:query>
</sql:execute-query>
<!-- and at this point you can include additional queries or XIncludes or other good stuff not in the example -->
</document>
</xsl:template>
</xsl:stylesheet>


Presumably there are Good Things one could do in the XSL Transformation to validate the parameters from the URL and to ensure Unpleasant Things didn't come along for the ride. I would *love* to see some examples of the kinds of things people actually do.

The XML coming out of this should be ready for the SQLTransformer to act on it.

I haven't been following along for long enough to know if the SQLTransformer is considered Due For Deprecation. If it isn't, a use case with URL submitted parameters would be a useful enhancement to the documentation.

Walter Lewis
virtual Cocoon newbie


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to