> From: Peter Wieland [mailto:[EMAIL PROTECTED]] 
> 
> Hi,
> 
> I'm trying for one day to get a logicsheet to do some work 
> for me. I want to print out a drop down menu with values from 
> a database and the format speciefied in my xsp source.
> 
> here is the relevant part of the xsp-page (test.xsp)
> ---------------------------------
>     <list>
>       <tiana-sql:listboxitems table="TianaUser">
>         <tiana-sql:itemelement 
> type="column">Id</tiana-sql:itemelement>
>         <tiana-sql:itemelement type="text"> - </tiana-sql:itemelement>
>         <tiana-sql:itemelement 
> type="column">FirstName</tiana-sql:itemelement>
>         <tiana-sql:itemelement type="text"> </tiana-sql:itemelement>
>         <tiana-sql:itemelement 
> type="column">LastName</tiana-sql:itemelement>
>       </tiana-sql:listboxitems>
>     </list>
> ---------------------------------
> 
> and some parts of my tiana-sql logicsheet
> ---------------------------------
> <xsl:template name="get-columns">
>   <xsl:for-each select="tiana-sql:itemelement[@type='column']">
>     <xsl:text>, </xsl:text>
>     <xsp:logic>TianaSQLHelper.getTablePrefix(objectModel, 
> "<xsl:value-of 
> select="parent::*/@table"/>")</xsp:logic><xsl:value-of select="."/>
>   </xsl:for-each>
> </xsl:template>

If you are going to output something with this code then you should use
<xsp:expr> instead of <xsp:liogic>

> 
> <xsl:template match="tiana-sql:listboxitems[@table]">
>   <xsl:variable name="idcolumn">
>     <xsp:logic>TianaSQLHelper.getIdColumn(objectModel, 
> "<xsl:value-of select="@table"/>")</xsp:logic>

This won't work: logicsheet is applied before any code is run, so you can't
assign a value to XSL variable. Use normal Java variables for that.

>   </xsl:variable>
> 
>   <xsl:variable name="in-cond">
>     <xsl:if test="@in-cond"> WHERE <xsl:value-of 
> select="$idcolumn"/> IN (<xsl:value-of select="@in-cond"/>)</xsl:if>
>   </xsl:variable>
> 
>   <esql:connection>
>     <esql:pool>tiana</esql:pool>
>     <esql:execute-query>
>       <esql:query>
>         <xsl:text>SELECT </xsl:text>
>         <xsp:logic>TianaSQLHelper.getIdColumn(objectModel, 
> "<xsl:value-of select="@table"/>")</xsp:logic>

The same is here: use xsp:expr

>         <xsl:text> AS Id</xsl:text>
>         <xsl:call-template name="get-columns"/>
>         <xsl:text> FROM </xsl:text><xsl:value-of select="@table"/>
>         <xsl:value-of select="$in-cond"/>
>       </esql:query>
>       <esql:results>
>         <esql:row-results>
>           <item>
>             <value><esql:get-string column="Id"/></value>
>             <text>
>               <xsl:for-each select="tiana-sql:itemelement">
>                 <xsl:choose>
>                   <xsl:when test="@type='text'">
>                     <xsl:value-of select="."/>
>                   </xsl:when>
>                   <xsl:when test="@type='column'">
>                     <!--<esql:get-string>
>                       <esql:column>-->
>                       
> <xsp:logic>TianaSQLHelper.getTablePrefix(objectModel,
> "<xsl:value-of select="parent::*/@table"/>") + "<xsl:value-of 
> select="."/>"</xsp:logic>

And here

>                       <!--</esql:column>
>                     </esql:get-string>-->
>                   </xsl:when>
>                 </xsl:choose>
>               </xsl:for-each>
>             </text>
>           </item>
>         </esql:row-results>
>       </esql:results>
>     </esql:execute-query>
>   </esql:connection>
> </xsl:template>
> ---------------------------------

Although, I might have understood your code a little wrong. See my
logicsheet sample:
http://www.cocooncenter.org/cc/documents/resources/logicsheet/index.html -
this is a simple demonstration of what you are going to achieve.

> 
> This works fine as long as I comment out the part, where I 
> actually do the db request (I just get the names of the 
> columns printed out, instead of the columns). But if I 
> include this request, I get class not found exceptions, what 
> is not very surprising as an empty test_xsp.java file is 
> generated. But why is this file empty. When I use <xsp:expr> 
> ... </> instead of logic, I get an compile error because of a 
> missing ";" in my test_xsp.java.

You are mixing your code with ESQL's, this can be the cause of the problem.

> 
> Can anybody give me a hint how I could get my application working?

It's a little difficult not seeing the stylesheet in all.

> 
> By the way, I never really understood when to use xsp:expr 

When you want to output something (just like <%= %> in JSP)

> and xsp:logic 

This is for performing some Java code, say declaring variables (like <% %>
in JSP). Note, that xsp:logic does not output anything.

>or both of them. And what is the sense of xsp:component?

Never used it before. Is there anybody who knows what is it?

--
Konstantin Piroumian 
[EMAIL PROTECTED]

> 
> Thanks for any help,
> 
> Peter
> 
> ---------------------------------------------------------------------
> Please check that your question has not already been answered 
> in the FAQ before posting. 
<http://xml.apache.org/cocoon/faqs.html>

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

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

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

Reply via email to