Subject: Re: [xsl] Binding a variable within a "value-of select" From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 25 Oct 2005 13:51:47 +0100 |
> I was thinking to use the { } as a solution. {} is never Xpath syntax, so <xsl:value-of select="WBSLServiceData/{$addorDef}/PostCode"/> <xsl:value-of select="{WBSLServiceData/$addorDef/PostCode}"/> are both syntax errors <xsl:value-of select="WBSLServiceData/$addorDef/PostCode"/> is legal syntax and if $addorDef contained a node set this would evaluate to some value, but you say that it contains a ___string___ so the above is equivalent to <xsl:value-of select="WBSLServiceData/'def'/PostCode"/> which is a type error you can't use a string in the middle of an Xpath. variables hold values, not fragments of Xpath syntax. If you have a variable foo in C (or Java or pretty much any other language you choose) that contained a string such as " + 1" you wouldn't expect to be able to use 2 foo to expand to 2 + 1 and so evaluate to 3. variables in XSL are (a bit) like variables in C they are not like C preprocessor macros. If you have a variable that contains Xpath syntax then you need an extension function that makes an Xpath parser available at run time. (eg saxon:evaluate) or if the variable is just a single element name the FFFFAQ answer is WBSLServiceData/*[name()=$addorDef]/PostCode David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Binding a variable within, António Mota | Thread | RE: [xsl] Binding a variable within, Michael Kay |
Re: [xsl] Binding a variable within, António Mota | Date | Re: [xsl] XPath 2.0 / XSLT 2.0 stat, David Carlisle |
Month |