开发者

XSL unexpected token $ error exception

I am a newbie to XSL programming. Could you please help me in solving this issue?

Is it possible to combine and fetch the values of two xsl:variable Example:

<xsl:variable name="path1" select="//path1"/>
<xsl:variable name="path2" select="//path2/value"/>

Then combine them using:

<xsl:value-of select ="$path1/$path2"/>

I want to fetch the value from path1 by com开发者_如何学Gobining the result from path2 If I use the above code I get unexpected token $ error

Is there any other alternative?


It sounds like you're possibly looking to do

<xsl:value-of select="concat($path1,$path2)" />

It's worth pointing out here that you're not actually storing the paths in those variables, but the nodes that those paths point to. i.e. $path1 does not contain //path1, but the value of whatever that node contains.

If you actually wanted the text '//path1//path2/value', then you need to define your path variables with

<xsl:value-of select="path1" select="'//path1'" />
<xsl:value-of select="path2" select="'//path2/value'" />

(note the extra ' that indicates it's a text value rather than an xpath). The same <xsl:value-of statement above will give you output of '//path1//path2/value' in this case.

If you actually want the contents of the //path1//path2/value node, it's a lot trickier, and it's more than likely there's a better way of doing whatever it is you're trying to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜