[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: dynamic construction of path based on param
raven wrote:
A number of mistakes: local variable's scope is its parent element, so both of your variables go out of the scope immediately. Second - variables are not macros, <xsl:variable name="path" select="x510" /> means the variable is bound to *result* of evaluation of 'x510' xpath expression. And syllabus/$path is syntax error in XPath.I want to dynamically construct a path based on a param called $course. Here is my current code: What you can do (but it looks a litle bit strange) is <xsl:variable name="path"> <xsl:if test='contains($course, "510")'> <xsl:value-of select="x510" /> </xsl:if> <xsl:if test='contains($course, "340")'> <xsl:value-of select="x340" /> </xsl:if> </xsl:variable> <xsl:apply-templates select='syllabus/*[local-name() = $path]'/> But that looks like a very convolute (and namespace-buggy) version of <xsl:if test='contains($course, "510")'> <xsl:apply-templates select='syllabus/x510'/> </xsl:if> <xsl:if test='contains($course, "340")'> <xsl:apply-templates select='syllabus/x340'/> </xsl:if> -- Oleg Tkachenko eXperanto team Multiconn Technologies, Israel 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
|