Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

how to use XSL

I have an XSL that I am using during an XML transformnode()

an XML fragment is something like
<retailer>
<index>1</index>
<name>My Store</name>
</retailer>

I would like to generate the following HTML
<a href="mypage.asp?retailid=1>My Store</a>

I tried...
<a>
<xsl:attribute name="href=mypage.asp?retailid">
<xsl:value-of select="index"/>
</xsl:attribute>
<xsl:value-of select="name"/>
</a>

But this resulted in...
<a href="mypage.asp?retailid="1">My Store</a>

How can I get rid of the "" around the id number?

TIA,

Phil
[726 byte] By [Phil Pastor] at [2007-11-9 14:55:30]
# 1 Re: how to use XSL
Phil,
Try this

<a>
<xsl:attribute name="href">
"mypage.asp?retailid="<xsl:value-of select="index"/>
</xsl:attribute>
<xsl:value-of select="name"/>
</a>

This should work.

<xsl:attribute ..> tag is meant to declare the properties of the tag ("href")
like name etc. the value you want the attrib to contain should exist in between
those
<xsl:attribute ..> and <xsl:attribute/>

Rohit
Rohit Wason at 2007-11-11 23:33:52 >
# 2 Re: how to use XSL
Rohit,

Thanks for the advice. Your solution did remove the quote marks, however,
now the output is ...

<a href="mypage.asp?retailid= 1">My Store</a>

If you can't see it here, I have the index number 1 preceded by 32 spaces.
Anyway to trim these spaces during the transformation?

Thanks again,

Phil

"Rohit Wason" <rohitw@futuresoftindia.com> wrote:
>
>Phil,
>Try this
>
><a>
> <xsl:attribute name="href">
> "mypage.asp?retailid="<xsl:value-of select="index"/>
> </xsl:attribute>
> <xsl:value-of select="name"/>
></a>
>
>This should work.
>
><xsl:attribute ..> tag is meant to declare the properties of the tag ("href")
>like name etc. the value you want the attrib to contain should exist in
between
>those
><xsl:attribute ..> and <xsl:attribute/>
>
>Rohit
Phil Pastor at 2007-11-11 23:34:56 >
# 3 Re: how to use XSL
Use VBScript's Trim() method
in <xsl:script></xsl:script> declaration
Rohit
Rohit Wason at 2007-11-11 23:35:50 >