cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yann" <ylelo...@ims.ltd.uk>
Subject XSL variable name usage
Date Wed, 26 Apr 2000 14:54:02 GMT
Sorry if this is not that Cocoon related, but I am stuck and I have tight
deadlines to demonstrate my Coccon project.

In my XSL document, I want to compare the value of a temporary XSL variable
with an element attribute from my XML document (an item element) so that I
can decide which item to be the selected value in a combobox:

<xsl:template match="Combobox">
  <select name="combovalue" >
   <xsl:variable name="selecteditem" select="@selected" />
   <xsl:apply-templates />
  </select>
 </xsl:template>

<xsl:template match="Item">
  <xsl:element name="option">
   <xsl:if test="itemcode=$selecteditem">
    <xsl:attribute name="selected">true</xsl:attribute>
   </xsl:if>
   <xsl:attribute name="value"><xsl:value-of select="itemcode"
/></xsl:attribute>
   <xsl:value-of select="itemstring" />
  </xsl:element>
 </xsl:template>

I get:

org.apache.xalan.xslt.XSLProcessorException: pattern =
'itemcode=$selecteditem'
VariableReference given for variable out of context or without definition!
Name = selecteditem

It's not very difficult what I want to do (have a temporary variable to use
in another template). I imagined it would be visible from children nodes
though.

Thanks for your help,

Yann, nearly finishing his first Cocoon-based web-app.



Mime
View raw message