Re: [xsl] Concatenating multiple variables in a XPath statement

Subject: Re: [xsl] Concatenating multiple variables in a XPath statement
From: "Mohsen Saboorian" <mohsens@xxxxxxxxx>
Date: Tue, 20 Jun 2006 11:02:58 +0330
Thank you Micheal.
There are xpath and element names in the variables. var1 contains an
xpath like /form/body/rows/row[$i] and var2 has an element name which
is found dynamically in a loop.
I think this is the case that XPath does not support. Am I right?

Thanks.

On 6/20/06, Michael Kay <mike@xxxxxxxxxxxx> wrote:
You don't say what's in the variables.

If the variables hold element names, you can do

*[name()=$var1]/*[name()=$var2]

If the variables hold more than this, for example if they hold fragments of
XPath like "@att" or "following-sibling::text()" then this approach doesn't
work, you need to use an extension such as saxon:evaluate() which allows
dynamic construction of XPath expressions.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Mohsen Saboorian [mailto:mohsens@xxxxxxxxx]
> Sent: 20 June 2006 07:15
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Concatenating multiple variables in a XPath statement
>
> Hi,
> I want to know if it is possible to make a XPath with
> multiple variables, something like "$var1/$var2". This kind
> of query has errors. In fact I think that placing a "/" befor
> $ makes the problem.
> How can I use a query like this:
> <xsl:value-of select="/rootElement/body/$colName" /> or
> <xsl:value-of select="/$var1/$var2" />
>
> Thanks in advance.

Current Thread