Veiw images with XML and XSLT

T

thomas

Hi folks,

I was wandering how to output images using XML and XSLT. I've tried but I
can't get it to work

I've used XML and XSLT before but it was in a different format. See for
yourself :-
http://www.guitarmidi.co.uk/gui/index.html
but here I didn't use any images and I only output 1 result per table row.

What I want to do now is output 4 results per table row and I want to use
some images. I would like to have the image and the name of the artist in a
cell and when you click on the image it takes you to the official website of
the artist.

part of the output.xsl file
================

<xsl:variable name="link1"><xsl:apply-templates select="./link"
/></xsl:variable>
<td><a href="{$link1}" target="_blank"><code to show image></a></td>
<td><xsl:apply-templates select="./artist" /></td>

I have a directory called images with the images I want to use
(rolling_stones.jpg, beatles.jpg etc)

heres my data.xml file
==============
<catalogue>
<record>
<artist>rolling stones</beatles>
<link>http://www.rollingstones.com/home.php</link>
</record>
<record>
<artist>beatles</beatles>
<link>http://www.beatles.com</link>
</record>
<record>
<artist>david bowie</beatles>
<link>http://www.davidbowie.com</link>
</record>
<record>
<artist>bob dylan</beatles>
<link>http://www.bobdylan.com/index.html</link>
</record>
</catalogue>

Any help with this would be appreciated.
 
T

Tjerk Wolterink

thomas said:
Hi folks,

I was wandering how to output images using XML and XSLT. I've tried but I
can't get it to work

I've used XML and XSLT before but it was in a different format. See for
yourself :-
http://www.guitarmidi.co.uk/gui/index.html
but here I didn't use any images and I only output 1 result per table row.

What I want to do now is output 4 results per table row and I want to use
some images. I would like to have the image and the name of the artist in a
cell and when you click on the image it takes you to the official website of
the artist.

part of the output.xsl file
================

<xsl:variable name="link1"><xsl:apply-templates select="./link"
/></xsl:variable>
<td><a href="{$link1}" target="_blank"><code to show image></a></td>
<td><xsl:apply-templates select="./artist" /></td>

I have a directory called images with the images I want to use
(rolling_stones.jpg, beatles.jpg etc)

heres my data.xml file
==============
<catalogue>
<record>
<artist>rolling stones</beatles>
<link>http://www.rollingstones.com/home.php</link>
</record>
<record>
<artist>beatles</beatles>
<link>http://www.beatles.com</link>
</record>
<record>
<artist>david bowie</beatles>
<link>http://www.davidbowie.com</link>
</record>
<record>
<artist>bob dylan</beatles>
<link>http://www.bobdylan.com/index.html</link>
</record>
</catalogue>

Any help with this would be appreciated.

this is easy:

<record>
<image>path/to/image.jpg</image>
</record>

: xsl:

<template match="image">
<img src="{.}" />
</template>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Duplicate XSLT Output 1
XSLT Question 1
XML to XML using XSLT 1
Search XML Node 1
Merging tables with XSLT 2
XSL page output 0
Help with my responsive home page 2
XSLT filtering based on attribute value 2

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top