You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ira Rodens <ir...@hekimian.com> on 2001/01/04 20:07:04 UTC
XSP instance variables
Hi,
I am playing around with xsp taglibs. I want to to have a java variable
which is re-initialized for each page request. It seems that whether or not
I make the variable static or not the value carries through from request to
request and the count keeps incrementing.
Is there to have a separate instance of the variable for each page fetched?
The logic sheet that I am using is,
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:count="http://www.hekimian.com"
version="1.0"
>
<xsl:template match="xsp:page">
<xsp:page>
<xsl:processing-instruction
name="cocoon-format">type="text/xml"</xsl:processing-instruction>
<xsl:copy>
<xsl:apply-templates select="@*"/>
</xsl:copy>
<xsp:logic>
int count = 1;
private int getCount() {
return count++;
}
</xsp:logic>
<xsl:apply-templates/>
</xsp:page>
</xsl:template>
<xsl:template match="count:value">
<xsp:expr>getCount()</xsp:expr>
</xsl:template>
<xsl:template match="@*|*|text()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Ira Rodens
Technogy Consultant
Hekimian