hi i have my xml code below:

<?xml-stylesheet type="text/xsl" href="book.xsl" version="1.0"?>
<books xmlns:xsd = "http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation = "book.xsd">
	<book id="001">
		<isbn>0465044050</isbn>
		<title>Birth of the Mind</title>
		<author>
			<firstname>Gary</firstname>
			<lastname>Marcus</lastname>
		</author>
		<publisher>Basic Books</publisher>
		<year>2004</year>
		<price>17.68</price>
		<picture>0465044050.gif</picture>
		<description>write your desc.</description>	
		
	</book>

</books>

and here my xsl code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/">
	<html>
		<head><title align="center">Books published after 2000</title></head>
		<body>
			<table align="center" border="1">
			<tr>
				<th>Photo</th>
				<th>ISBN</th>
				<th>Title</th>
				<th>author</th>
				<th>Publisher</th>
				<th>Year</th>
				<th>Price</th>
			</tr>
			
			<xsl:for-each select="books/book">
			<tr>
				<td><img src="book.gif"></img></td>
				<td><xsl:value-of select="isbn"/></td>
				<td><xsl:value-of select="title"/></td>
				<td><xsl:value-of select="author/firstname"/>,<xsl:value-of select="author/lastname"/></td>
				<td><xsl:value-of select="publisher"/></td>
				<td><xsl:value-of select="year"/></td>
				<td><xsl:value-of select="price"/></td>
			</tr>
			</xsl:for-each>
			</table>
		</body>
	</html>
    </xsl:template>
</xsl:stylesheet>

But the problem is that i need to insert different pictures in different rows. The way i have done it, the same picture is appearing on all rows. I have no idea how to do this. Can someone help me?

Recommended Answers

All 3 Replies

You have hard-coded the image value to be book.gif. Change

<td><img src="book.gif"></img></td>

to

<td><img src="{picture}"></img></td>
commented: Its helpfull n thanks +0

ok thx

This is really helpfull thanks all.. i settle mine problem too :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.