Subject: Re: [xsl] use variable in <xsl:if test= From: Matt Gushee <mgushee@xxxxxxxxxxxxx> Date: Fri, 1 Mar 2002 17:19:47 -0700 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] use variable in <xsl:if t, Wendell Piez | Thread | Re: [xsl] use variable in <xsl:if t, Robert Sösemann |
Re: [xsl] use variable in <xsl:if t, Wendell Piez | Date | Re: [xsl] use variable in <xsl:if t, Matt Gushee |
Month |