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

passing XSL variables

Subject: passing XSL variables
From: Jenny Simpson <simpson@xxxxxxxxxxx>
Date: Tue, 10 Jul 2001 18:32:29 -0600
xsl variable passing
This question has probably been answered several times, but I was unable
to find it in the archives so I'll risk repetition.  I want to pass a
variable as the name of an xml child element but the variable isn't
being interpreted the way I need it to be.  For example, 
here is the XML node:
    <bibitem type="unpublished" label="Hough62">
        <author>
            <firstname>P.</firstname>
            <middlename>V.</middlename>
            <middlename>C.</middlename>
            <lastname>Hough</lastname>
        </author>
        <title>Method and Means of Recognizing Complex Patterns</title>
        <year>1962</year>
        <note>U.S. Patent 3,069,654</note>
    </bibitem>

I want to use the following bit of code to search the xml document for
nodes whose year matches a variable $search.

<xsl:choose>
	<xsl:when test="$search">
		<xsl:for-each select="bibliography/bibitem">
		<xsl:if test="($search=year)">
...


However, instead of using the literal string 'year', I want to use a
variable containing the string 'year'.  However, if I substitute the
variable $field (which contains 'year') for 'year', as follows, the
comparison doesn't work. 

<xsl:choose>
	<xsl:when test="$search">
		<xsl:for-each select="bibliography/bibitem">
		<xsl:if test="($search=$field)">
...

I've tried using single quotes, parentheses, and even the substring
function to get the variable to be interpreted as it should be, but to no
avail.  I'd be interested in any tips on using xsl variables in
general.  Thanks in advance.

Jenny Simpson
Sci Institute


 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.