Re: [xsl] choose/otherwise not doing anything?

Subject: Re: [xsl] choose/otherwise not doing anything?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 15 Oct 2002 20:25:42 +0100
Hi Richard,

> I'm sure I'm doing something really stupid, but I cant figure out
> for the life of me why the following template always outputs and
> empty element.

Yeah, you're doing something really stupid -- you've just missed some
quotes :) You're doing:

  <xsl:value-of select='positive'/>

when you mean to do:

  <xsl:value-of select="'positive'"/>

though personally, I'd just use literal text rather than an
<xsl:value-of> instruction:
  
<xsl:template match="medical_assessment/tb_test_positive |
                     medical_assessment/hiv_test_positive">
  <xsl:copy>
    <xsl:choose>
      <xsl:when test=". = 'true' or . = '1'">positive</xsl:when>
      <xsl:when test=". = 'false' or . = '0'">negative</xsl:when>
      <xsl:otherwise>otherwise</xsl:otherwise>
    </xsl:choose>
  </xsl:copy>
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread