xsl-list
[Top] [All Lists]

RE: [xsl] variables

2006-06-09 03:49:00
When global variables are evaluated, the context node is the root node of
the initial source document. Is the outermost element of this document
called "group"? If not, all your xsl:when conditions are going to fail.

Your use of the name "counter" for your variables makes me suspicious that
you are treating these variables as if they were mutable... but you haven't
shown enough of your stylesheet to justify this.

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Mark Williams [mailto:mark(_at_)gwsmartmove(_dot_)co(_dot_)uk] 
Sent: 09 June 2006 11:17
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] variables

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[(_at_)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[(_at_)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[(_at_)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[(_at_)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[(_at_)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(_at_)gwsmartmove(_dot_)co(_dot_)uk
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. 


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>