[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: variables

Subject: RE: variables
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 9 Jun 2006 11:44:47 +0100
xsl when variable
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@xxxxxxxxxxxxxxxxx] 
> Sent: 09 June 2006 11:17
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  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[@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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.