<map:transform type="sql">
   <map:parameter name="use-connection" value="personnel"/>
   <map:parameter name="show-nr-of-rows" value="true"/>
   <map:parameter name="username" value="{request-param:username}"/>
 </map:transform>


Upayavira


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.

Yes, I have read the docs. And I remain somewhat confused.

What I want to do: Select a db record (MySQL db, Cocoon 2.1) based on a
value submitted by a form.

The documentation on the SQLTransformer suggests the following:

 <page xmlns:sql="http://apache.org/cocoon/SQL/2.0";>
   <execute-query xmlns="http://apache.org/cocoon/SQL/2.0";>
     <query>
      select id,name from employee_table where name =
               '<sql:substitute-value sql:name="username"/>'
     </query>
   </execute-query>
 </page>

However, the example for a "dynamic" pipeline is not much help:

 <map:transform type="sql">
   <map:parameter name="use-connection" value="personnel"/>
   <map:parameter name="show-nr-of-rows" value="true"/>
   <map:parameter name="username" value="Stefano Mazzocchi"/>
 </map:transform>

Now, this example demonstrates that the SQLTransformer is capable of using a
parameter, but what is the simplest way to get the value of "username" to
the sitemap from a form?

Note: This can be accomplished by creating a "dummy" XML file...
<content>
<dynamic-query/>
</content>

...and an XSL stylesheet to prepare the query BEFORE passing it to the SQL
transformer:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:sql="http://apache.org/cocoon/SQL/2.0";>

<xsl:param name="name"/>

<xsl:template match="/">
 <page>
  <title>Hello <xsl:value-of select="$name"/></title>
  <content>
   <xsl:apply-templates/>
  </content>
 </page>
</xsl:template>

<xsl:template match="dynamic-query">
 <execute-query xmlns="http://apache.org/cocoon/SQL/2.0";>
   <query>select * from portalusers where name= '<xsl:value-of
select="$name"/>'</query>
 </execute-query>
</xsl:template>

</xsl:stylesheet>


This is the method Lajos Moczar describes in "Cocoon Developer's Handbook" to achieve a truly dynamic query, and takes advantage of params in the first XSL.

However, this was before the tag, "sql:substitute-value" became available in
Cocoon 2.1,
so I would think this is easily implemented in some way... But, how?


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







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



Reply via email to