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

Re: use variable in <xsl:if test=

Subject: Re: use variable in <xsl:if test=
From: Matt Gushee <mgushee@xxxxxxxxxxxxx>
Date: Fri, 1 Mar 2002 17:19:47 -0700
html use variable
On Fri, Mar 01, 2002 at 06:55:41PM -0500, Wendell Piez wrote:

> In the code below, if you are setting the variable at the top level to be 
> available globally, and you want it to contain any element throughout that 
> contains an author element whose value is the string "C. J. Date", then try
> 
> <xsl:variable name="condition" select="//*[.//author='C. J. Date']"/>

But then, of course, the result would contain the root element -- which 
I'm guessing is not what you want. You are probably trying to distinguish
between certain elements below the root level that have 
<author>C. J. Date</author> as descendants.

Another problem with this is performance. That may not matter if you are
doing batch processing of static documents, but if you are generating 
dynamic HTML for your web server, you should try to avoid using '//'
whenever possible, especially at the top level of the stylesheet. That's
because the XSLT processor has to search the entire document tree. A
more specific path, such as:

  /catalog/foo/bar/book[normalize-space(.//author) = 'C. J. Date']

will solve that problem. The normalize-space() function is a good idea
whenever your stylesheet logic depends on the information contained
in certain elements. Note that my example above will only work if each
book has just one author.

If this suggestion and the others people have posted are not enough to
solve your problem, you might want to post a sample of your source
document (as well as explaining more of what you want to do).

-- 
Matt Gushee
Englewood, Colorado, USA
mgushee@xxxxxxxxxxxxx
http://www.havenrock.com/

 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.