Forum Moderators: open

Message Too Old, No Replies

xml node to xsl <img> tag display

need to turn a node into an image

         

MoonBunny

12:18 pm on Aug 14, 2006 (gmt 0)

10+ Year Member



Hello
I have been working with xml and xsl for only 2 months now and have come accross a problem I can not solve.
I need to use an xml node inside a <img> tag in my xsl file.

The xml file/feed comes from a servlet. (I can not get this changed, allready asked.)

<?xml version="1.0" encoding="UTF-8"?>
<Irace msg="WCResultResponse">
<Header>
<ReturnCode>0</ReturnCode>
<ReturnString>Success</ReturnString>
<TimeStamp>2006-08-04 14:16:39.00</TimeStamp>
</Header>
<Result EId="25423754" RaceNum="1" Track="Concours St. Tropez ">
<First FinishTime="59421" Name="Westerly Winds" PLC="4.1" SHW="2.9" Trap="1" WIN="7.4"/>
<Third FinishTime="59866" Name="Handsome" SHW="1.6" Trap="2"/>
<Second FinishTime="59820" Name="Surf Up" PLC="3.7" SHW="2.4" Trap="6"/>
<Exacta Desc="(1,6)" Payout="63.1"/>
</Result>
</Irace>

I want to use the nodes Trap="1" Trap="2" Trap="3" to display a gifs in my xsl doc.

normal? way of displaying an image
...
<td align="center" width="34" height="36">
<img hspace="0" src="D:\work\codere\xsl\1.gif"/>
</td>
...

What I want to do...
...
<td align="center" width="34" height="36">
<img hspace="0" src="D:\work\codere\xsl\<xsl:value-of select="Irace/Result/First/@Trap"/>.gif"/>
</td>
...

I get an "Expected Whitespace" error. I have spent the last few days trying to find example of what I want to do on the web and come up with nothing.

How do I turn,
<xsl:value-of select="Irace/Result/First/@Trap"/> (Trap="1")
into "1.gif"?

Forgive me if this question has allready been asked.

R. Kline

jay5r

1:02 pm on Aug 14, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



I just started working with XSL in the past week or two and and something just like that stumped me as well...

What worked for me is to use
{Irace/Result/First/@Trap}
instead of
<xsl:value-of select="Irace/Result/First/@Trap"/>
whenever your inside another tag.

So, basically put whatever would have been in your select attribute inside curly braces and you should be good.

MoonBunny

1:13 pm on Aug 14, 2006 (gmt 0)

10+ Year Member



Thank you for your reply.

Sorted and working now, I guess I still have lots more to learn.

I've learned all I know from;
[w3schools.com...]
Is there another online tutorial that's clean and simple to read that goes abit more indepth?

Thank you again

jay5r

1:46 pm on Aug 15, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



I'm using Dreamweaver 8 to do my xslt templates. It's far from perfect, but it's helped a lot with my learning. When you drag and drop a bound element into your stylesheet, it usually gets it right.