|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Binding a variable within a "value-of select"
> 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
________________________________________________________________________
|
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
|

Cart








