conditional processing in templates

Subject: conditional processing in templates
From: "Jon Smirl" <jonsmirl@xxxxxxxxxxxx>
Date: Thu, 22 Jul 1999 00:49:10 -0400
I'm working on some forms processing code. Sometimes my display of a field
needs a label and sometimes it does not.

So I tried to write a template like this:

  <xsl:template mode="display" match="*[@type='date']">
  <xsl:attribute name="title"><xsl:value-of
  <xsl:if test="$label=1">
   <xsl:value-of select="local-part()"/>:
  <xsl:value-of select="."/>
.. repeated for many variable types...

And then call it with:

 <xsl:template match="employee">
  <xsl:variable name="label">1</xsl:variable>
  <table width="100%" border="1">
    <td><xsl:apply-templates mode="display" select="First"/></td>
    <td><xsl:apply-templates mode="display" select="Last"/></td>

But this doesn't work because $label would be a side effect.

Can this be done without duplicating the first template, one for labels and
one without?

Thank for the help,
Jon Smirl

 XSL-List info and archive:

Current Thread