passing XSL variables
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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format