Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 21st, 2006, 10:32 AM
Authorized User
 
Join Date: May 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Rendering images with XSLT

Hiya!

I have this XSL file that basically creates a list of dynamic anchors that when clicked take you to a news story with a graphic in the same page:

Code:
<?xml version="1.0"?>
<xsl:transform
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:template match="/">
    <html>
      <head/>
      <body bgcolor="#777777">
      <img src="HEADER.jpg" />
        <h2 id="contents">News Articles</h2>



        <xsl:apply-templates mode="toc"/>





        <xsl:apply-templates/>



      </body>
    </html>




  </xsl:template>

   <xsl:template match="Article" mode="toc">
    <a href="#{ArticleTitle}" ><xsl:value-of select="ArticleTitle"/></a><br/>
  </xsl:template>


  <xsl:template match="Article">
    <div>
      <h2><a name="{ArticleTitle}"><xsl:value-of select="ArticleTitle"/></a></h2>
      <xsl:apply-templates/>
    </div>
  </xsl:template>


  <xsl:template match="ArticleTitle"/>


 <xsl:template match="ArticleEntry">
 
 
<p><img src="{ImageLoc}" width="100px" height="100px" id="image"/></p>

<p><a href="trans_XML_TV.php">back to story links</a></p>
<p><a href="index.html">home</a></p>

    <p><xsl:apply-templates/></p>

 <p><a href="trans_XML_TV.php">back to story links</a></p>
<p><a href="index.html">home</a></p>

  </xsl:template>

</xsl:transform>
Problem is the graphic does not display (where ImageLoc is the node in the XML containing the path to the image):

Code:
<p><img src="{ImageLoc}" width="100px" height="100px" id="image"/></p>
In the HTML source comes out like this:

Code:
<p><img src="" width="100px" height="100px" id="image"/></p>
Does anyone know what I am doing wrong?


Cheers!

 
Old May 21st, 2006, 11:37 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You haven't shown your XML source document but the obvious explanation would be that the ArticleEntry element does not have a child element called ImageLoc.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Captcha Script not rendering images - broken crmpicco Beginning PHP 2 October 13th, 2007 07:45 AM
XSLT rendering problems in IE7 for Vista tripecac XSLT 17 July 4th, 2007 10:07 AM
Rendering base64 images from XML in XSLT jilly XSLT 7 June 29th, 2007 07:56 AM
images with xslt chris davies XSLT 2 December 9th, 2005 05:36 AM
XSLT and images humour XSLT 1 June 22nd, 2005 01:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.