using variable value in href XSL
Asked Answered
P

2

6

I knw its pretty basic question but I have just started reading it...

I have a variable name

<variable name="NAME">
http://www.yahoo.com/<xsl:value-of select="$someothervariable"/>
</variable>

and i want to use it in like this

I have used these two approaches but it didn't work

<a href="{NAME}">HELLO</a>
<a href="<xsl:value-of select="$NAME"/>

Any idea how to achieve this...

Thanks,

Polypoid answered 7/1, 2010 at 23:29 Comment(0)
H
14

You need to combine your two approaches:

<xsl:variable name="NAME">yourValue</xsl:variable>
<a href="{$NAME}" />
Heddy answered 7/1, 2010 at 23:51 Comment(4)
Can you provide some more context on your XSL? It could be a variable scoping issue. Or are there conditionals where your variable is first set?Heddy
Its working fine but there is empty spaces before and after the value in a tag.Polypoid
That'll be the newlines you have surrounding your expression in the <variable></variable> tag. Try removing those newlines to get rid of leading/trailing spaces.Heddy
How do you use the same variable URL for multiple anchor tags? If I do another <a href="{$NAME}" /> tag, on the web page it simply tries to link to "NAME".Stylite
K
1
<a>
    <xsl:attribute name="href">
        <xsl:value-of select="//YOUR_VAR_NAME"/>
    </xsl:attribute>
    LINK_TEXT
</a>
Katelynnkaterina answered 8/9, 2020 at 10:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.