You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Oleg Konovalov <ol...@yahoo.com> on 2005/11/09 00:27:10 UTC

Simple DB report

Hi,

I am trying to implement a popup which displays
on the screen data from several SQL queries (with parameter
passed, e.g.  "myurl?param1=123") using sitemap actions
with Cocoon 2.0.4. It is an addition to a large Cocoon app,
but none of older developers is around anymore. 
I am Cocoon newbie (was trying to follow their style,
but there are no similar things in that app).

So far I am getting a popup with parameter passed,
but it XSL page that parameter isn't getting picked up.
Instead I am getting on a screen a query text:
 "select ... from ... where cust_id=".

Here is what I have in sitemap:
<map:match pattern="custdata_popup">  
  <map:act type='request'>
    <map:parameter name="parameters" value="true"/>
    <map:generate src='xml/custdata_query.xml'/>
    <map:transform type="sql">
      <map:parameter name="cust_id" value="{cust_id}"/>
      <map:parameter name="use-connection" value="mbrdb"/>
      <map:parameter name="show-nr-of-rows" value="true"/>
    </map:transform>
    <map:transform type="xslt"
src="xslt/mbr/change_custdata_popup.xsl">
      <map:parameter name="use-request-parameters"
value="true"/>
    </map:transform>
    <map:serialize type="html"/>
  </map:act>
</map:match>

Here is a piece from the query file:
<xsl:param name='param1'/>
<content>  
<sql:execute-query>
  <sql:query name="cust_data">
    SELECT  col1, col2, col3
    FROM  cust_table
    WHERE  cust_id = <sql:substitute-value sql:name="param1"/>
  </sql:query>
  </sql:execute-query>
.... 
</content>

It seems that it is totally ignored,
at least XSL doesn't seem to get any output from SQLTransformer.
So I tried to execute that Select there directly.

Here is a main piece of my XSL file:
<?xml version='1.0' encoding='UTF-8'?>
<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='param1'/>

<xsl:variable name='thedata'
select='/page/content/paging/data'/>

<xsl:template match="/">
	<page>
		<title>Customer Data popup</title>
		<content>
			<xsl:apply-templates />
			<sql:execute-query>
				<sql:query>
				   SELECT  col1, col2, col3
    FROM  cust_table
    WHERE  cust_id = <sql:substitute-value sql:name="param1"/>	
				</sql:query>
			</sql:execute-query>
		</content>
	</page>
</xsl:template>

<xsl:template name='page-main'> 
	<form name="myformname" id="myform" method="post"
action="myaction">
<table 
<thead>
...
</thead>
  <tbody>
    <xsl:for-each select='$thedata/row'>
      <xsl:call-template name='row'>
	<xsl:with-param name='therow' select='.'/>
      </xsl:call-template>
  </xsl:for-each>
  </tbody>
</table>
</form>
</xsl:template>


<xsl:template name="row">
	<xsl:param name='therow'/>
<tr>
  <td align="left" valign="middle"><xsl:value-of  
select='$therow/col1'/></td>
...
</tr>
</xsl:template>

</xsl:stylesheet>


1) Could you please point me to some good example
of such simple (select) DB report ?

2) How do I pick up that parameter "param1" in XSL ?

3) why do I get a query text on the screen 
instead of the result of the query ?

4) Unless there is something wrong in my sitemap,
I think I can't get anything from SQL transformer
because I am trying to read it from incorrect place:
<xsl:variable name='thedata'
select='/page/content/paging/data'/>

Is there a standard place for the output of SQL Transformer?
Or where is it specified ?

5) Is it valid to put queries in XSL files 
or is it a bad practice?  
(as I said, there will be several queries for that screen).

Just need to connect it all together  ;-)


Any help is very appreciated.

TIA,
Oleg.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org