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

Re: Length of a variable?

Subject: Re: Length of a variable?
From: Steve Tinney <stinney@xxxxxxxxxxxxx>
Date: Wed, 15 Mar 2000 13:58:33 -0500
length of a variable access
> <xsl:variable name="colours" select="colour"/>
> 
> Further on in the stylesheet, there is to be a branch on whether
> $colours contains any colur elements or not. 

You are almost there.  You are setting $colours to a node-set containing
the colour elements which are the children of the context node.  You can
then get the number of elements in $colours with count($colours).

A mindset question, though: is it really necessary to store this in a
variable?  Not using a variable gets you out of having to test the
number of colours at some point where the variable would be in scope.

In general with XSL, you can frequently replace the use of a variable
with the direct access to the data that XPath gives you.  For example,
you might do:

 <xsl:if test="count(../paint/colour)">

depending on the context, of course.

 Steve


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


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.