[xsl] variables

Subject: [xsl] variables
From: "Mark Williams" <mark@xxxxxxxxxxxxxxxxx>
Date: Fri, 9 Jun 2006 11:17:18 +0100
Hi,

I'm trying to increment a paragraph number depending on whether various
options are true. I'm doing this by declaring variables as in the
following example:

- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format";>
- <xsl:variable name="counter2">
- <xsl:choose>
- <xsl:when test="group[@name='Outgoings']/council_tax=1">
  <xsl:value-of select="2" />
  </xsl:when>
- <xsl:otherwise>
  <xsl:value-of select="1" />
  </xsl:otherwise>
  </xsl:choose>
  </xsl:variable>
- <xsl:variable name="counter3">
- <xsl:choose>
- <xsl:when test="group[@name='Outgoings']/gas_charge=1">
  <xsl:value-of select="$counter2+1" />
  </xsl:when>
- <xsl:otherwise>
  <xsl:value-of select="$counter2" />
  </xsl:otherwise>
  </xsl:choose>
  </xsl:variable>
- <xsl:variable name="counterB">
- <xsl:choose>
- <xsl:when test="group[@name='Tenant_Obligations']/internal_repairs=1">
  <xsl:value-of select="2" />
  </xsl:when>
- <xsl:otherwise>
  <xsl:value-of select="1" />
  </xsl:otherwise>
  </xsl:choose>
  </xsl:variable>
- <xsl:variable name="counterC">
- <xsl:choose>
- <xsl:when
test="group[@name='Tenant_Obligations']/internal_decorations=1">
  <xsl:value-of select="$counterB+1" />
  </xsl:when>
- <xsl:otherwise>
  <xsl:value-of select="$counterB" />
  </xsl:otherwise>
  </xsl:choose>


Even though I know test="group[@name='Outgoings']/council_tax=1" is
evaluating to 1 later in the xsl (it inserts a particular paragraph of
text), counter2 is always evaluating to 1.

counterB, interestingly was working as expected, ie evaluating to 2.
However, I then noticed that the group name ie Tenant_Obligations was
incorrectly referenced in the xsl as "Tenant Obligations" (ie no
underscore). When I corrected this, counterB evaluates to 1 even though
internal_repairs is 1 and should therefore be evaluating to 2.

All this is very puzzling to me and leads me to believe that my variable
declarations are very very wrong.

Any help much appreciated.

Regards

Mark Williams

________________________________

GWSmartmove

24 St Andrews Crescent, Cardiff, CF10 3DD

E: enquiries@xxxxxxxxxxxxxxxxx
T: 02920375901
F: 02920375909

www.gwsmartmove.co.uk

The contents of this email and any attachments are the property of
Gimblett Williams Solicitors Limited and are intended for the
confidential use of the named recipient(s) only. If they have been
received by you in error please maintain confidentiality, notify us,
destroy copies and delete them from your computer. It is the
responsibility of the recipient to scan this email for viruses.

Current Thread