You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Chintalapaty, Sreedhar " <sc...@ptc.com> on 2003/07/11 20:58:47 UTC

Custom Logic Sheet, xsp:expr, etc.

Hi,

In my logic sheet, I have the need to pass a java variable into an XSL variable. For instance:

1.  <esql:results>
2.     <esql:row-results>
3.        <trans>
4.           <gvs-tag:row-id><esql:get-row-position/></gvs-tag:row-id>
5. 	       <xsp:logic>
6.              HashMap pAttributes = getItFromSomeWhere();
7.              String alias = (String) pAttributes.get("alias");

8.  		    <xsl:variable name="alias"><xsp:expr>String.valueOf(alias)</xsp:expr></xsl:variable>
9. 		    <gvs-tag:attribute>
10.		       <gvs-tag:value><esql:get-string><xsl:attribute name="column"><xsl:value-of select="$alias"/></xsl:attribute></esql:get-string></gvs-tag:value>
11.		    </gvs-tag:attribute>
12.	       </xsp:logic>
13.	    </trans>
14.    </esql:row-results>
15.  </esql:results>

	

GENERATED VERSION:
The Cocoon generated code for lines  9 - 10 is as follows:
	XSPObjectHelper.xspExpr (contentHandler, 
		EsqlHelper.getAscii(_esql_query.getResultSet(),
		"String.valueOf(alias)",
		"")
    	);

The problem is the quotes around String.valueOf(alias). When I run this, the query is run successfully, but the esql:get-string (lines 9-11) fails with the exception "Error getting ascii data for column String.valueOf(alias)". 

Obviously, it's trying to get the value of a column named "String.valueOf(alias)".

MODIFIED VERSION:
If I modify the generated code to
	XSPObjectHelper.xspExpr (contentHandler, 
		EsqlHelper.getAscii(_esql_query.getResultSet(),
		String.valueOf(alias),
		"")
    	);
by removing the quotes around String.valueOf(alias), and then compile the modified java source, it runs fine, getting me what I expect it to return.

The problem with this is that I have to modify the java source by hand every time I change the logic sheet. While this can be done in the short term, it is really not practical over the long term. So the question is: How can I write the logic scheet such that it will generate code that looks like the modified version above? 

Thanks for your help,

Sreedhar


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