homepage Welcome to WebmasterWorld Guest from 54.205.144.54
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
Images will not show in XML
moporho




msg:3750971
 4:29 am on Sep 24, 2008 (gmt 0)

I am very new to XML XSL. I tried created a xml file and a xsl file. The images will not appear in my table.

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="textcatalog.xsl"?>
<catalog>
<text>
<book><img alt="business" src="images/business2.jpg" /></book>
<title>Business Data Communications</title>
<edition>5th</edition>
<author>William Stallings</author>
<publisher>Prentice Hall</publisher>
<isbn>0-13-144257-0</isbn>
<year>2004</year>
<cover>Hardcover</cover>
<pages>604</pages>
<price>$ 97.60</price>
</text>

<text>
<book><img alt="C++" src="images/cpp2.jpg" /></book>
<title>C++ How to Program </title>
<edition>6th</edition>
<author>Deitel &amp; Associates Inc.</author>
<publisher>Prentice Hall</publisher>
<isbn>0-13-615250-3</isbn>
<year>2007</year>
<cover>Paperback</cover>
<pages>1504</pages>
<price>$ 103.50</price>
</text>

<text>
<book>
<img alt="Career" src="images/career.jpg" />
</book>
<title>Taking Charge of Your Career Direction: Career Planning Guide</title>
<edition>5th</edition>
<author>Robert D. Lock</author>
<publisher>Brooks Cole</publisher>
<isbn> 0-5345-7426-2</isbn>
<year>2004</year>
<cover>Paperback</cover>
<pages>504</pages>
<price>$ 69.25</price>
</text>

<text>
<book>
<img alt="Networking" src="images/net2.jpg" /></book>
<title>Computer Networking: A Top-Down Approach</title>
<edition>4th</edition>
<author>Kurose &amp;Ross</author>
<publisher>Addison Wesley</publisher>
<isbn>0-321-49770-8</isbn>
<year>2005</year>
<cover>Hardcover</cover>
<pages>880</pages>
<price>$ 77.08</price>
</text>

<text>
<book>
<img alt="Computer" src="images/ill.jpg" />
</book>
<title>Computer Science Illuminated </title>
<edition>3rd</edition>
<author>Dale &amp;Lewis</author>
<publisher>Jones &amp;Bartlett Publishers</publisher>
<isbn>0-7637-4149-3</isbn>
<year>2006</year>
<cover>Paperback</cover>
<pages>672</pages>
<price>$ 88.15</price>
</text>

<text>
<book>
<img alt="math" src="images/math.jpg" />
</book>
<title>Discrete Mathematics</title>
<edition>7th</edition>
<author>Richard Johnsonbaugh</author>
<publisher>Prentice Hall</publisher>
<isbn>0-13-135430-2</isbn>
<year>2009</year>
<cover>Paperback</cover>
<pages>766</pages>
<price>$ 76.88</price>
</text>

<text>
<book>
<img alt="Excel" src="images/excel.jpg" />
</book>
<title>Formulas and Functions with Microsoft Office Excel 2007</title>
<edition>1st</edition>
<author>Paul McFedries</author>
<publisher>Pearson Education, Inc</publisher>
<isbn>0-7897-3668-3</isbn>
<year>2007</year>
<cover>Paperback</cover>
<pages>552</pages>
<price>$ 26.39</price>
</text>

<text>
<book>
<img alt="Database" src="images/data.jpg" /></book>
<title>Fundamentals of Database Systems </title>
<edition>5th</edition>
<author>Elmasri &amp; Navathe </author>
<publisher>Addison Wesley</publisher>
<isbn>0-3213-6957-2</isbn>
<year>2006</year>
<cover>Hardcover</cover>
<pages>1168</pages>
<price>$ 88.29</price>
</text>

<text>
<book>
<img alt="Java" src="images/java2.jpg" />
</book>
<title>Java: An Introduction to Problem Solving and Programming</title>
<edition>4th</edition>
<author>Walter Savitch</author>
<publisher>Prentice Hall</publisher>
<isbn>0-13-149202-0</isbn>
<year>2005</year>
<cover>Paperback</cover>
<pages>1060</pages>
<price>$ 79.69</price>
</text>

<text>
<book>
<img alt="Access" src="images/access.jpg" />
</book>
<title>Microsoft Office Access 2007 Forms, Reports, and Queries</title>
<edition>1st</edition>
<author>Paul McFedrie</author>
<publisher>Que Publishing</publisher>
<isbn>0-7897-3669-1</isbn>
<year>2007</year>
<cover>Paperback</cover>
<pages>408</pages>
<price>$ 26.39</price>
</text>
</catalog>

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<html>
<body>
<h2>
<center>Textbook Warehouse</center>
</h2>
<table border="1">
<tr bgcolor="yellow">
<th align="center">Book</th>
<th align="center">Title</th>
<th align="center">Edition</th>
<th align="center">Author</th>
<th align="center">Publisher</th>
<th align="center">ISBN</th>
<th align="center">Year</th>
<th align="center">Cover</th>
<th align="center">Pages</th>
<th align="center">Price</th>
</tr>

<xsl:for-each select="catalog/text">
<tr>
<td>
<xsl:value-of select="book"/>
</td>
<td>
<xsl:value-of select="title"/>
</td>
<td>
<xsl:value-of select="edition"/>
</td>
<td>
<xsl:value-of select="author"/>
</td>
<td>
<xsl:value-of select="publisher"/>
</td>
<td>
<xsl:value-of select="isbn"/>
</td>
<td>
<xsl:value-of select="year"/>
</td>
<td>
<xsl:value-of select="cover"/>
</td>
<td>
<xsl:value-of select="pages"/>
</td>
<td>
<xsl:value-of select="price"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

what am I not doing right? I tried all sorts of ways, but still not go!

Cheers,
M

 

daveVk




msg:3750977
 5:25 am on Sep 24, 2008 (gmt 0)

<book><img alt="business" src="images/business2.jpg" /></book>

You have markup between the book tags, value-of will not return that, just the plain text content. Consider coding it as

<alt>business</alt>
<src>images/business2.jpg</src>

moporho




msg:3751094
 12:15 pm on Sep 24, 2008 (gmt 0)

I tried this method and in the space I got the text:

businessimages/business2.jpg

still no image.

cmarshall




msg:3751189
 2:35 pm on Sep 24, 2008 (gmt 0)

I'd say that the image isn't there, but it may be even simpler. Of course, you need to build this into a valid <img/> element, like so:

<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="book"/>
</xsl:attribute>
</xsl:element>

moporho




msg:3751233
 3:16 pm on Sep 24, 2008 (gmt 0)

Where would I place the build? I am so sorry but again I am extremely new to this.

daveVk




msg:3751668
 3:03 am on Sep 25, 2008 (gmt 0)

in place of

<td>
<xsl:value-of select="book"/>
</td>

try

<td>
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="src"/>
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="alt"/>
</xsl:attribute>
</xsl:element>
</td>

moporho




msg:3751678
 4:46 am on Sep 25, 2008 (gmt 0)

Nope that did not work either. This is a real mystery now. Thanks for the advice. I am baffled.
M~

daveVk




msg:3751690
 5:29 am on Sep 25, 2008 (gmt 0)

please post latest version you are trying, xml and xsl

cmarshall




msg:3751804
 10:31 am on Sep 25, 2008 (gmt 0)

By the way, you are using an application like Oxygen, XMLSpy or Stylus Studio, right?

I wouldn't even try writing XSLT without one.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved