473,573 Members | 2,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I want to display images using xslt. How can i do this? Not familliar with XSLT

4 New Member
I've converted the rest response to xml.
Here's my xml:

Expand|Select|Wrap|Line Numbers
  1. <Result>
  2.    <DressPrice>
  3.       <Name>Dress 2</Name>
  4.       <Price>20</Price>
  5.       <Image>2.jpeg</Image>
  6.    </DressPrice>
  7.    <DressPrice>
  8.       <Name>Dress 9</Name>
  9.       <Price>20</Price>
  10.       <Image>3.jpeg</Image>
  11.    </DressPrice>
  12.    <DressPrice>
  13.       <Name>Dress 10</Name>
  14.       <Price>20</Price>
  15.       <Image>0905C58A0179_1.jpeg</Image>
  16.    </DressPrice>
  17.    <DressPrice>
  18.       <Name>Dress 11</Name>
  19.       <Price>20</Price>
  20.       <Image>0905C58A0179_1.jpeg</Image>
  21.    </DressPrice>
  22.    <DressPrice>
  23.       <Name>Dress 12</Name>
  24.       <Price>20</Price>
  25.       <Image>0905C58A0179_1.jpeg</Image>
  26.    </DressPrice>
  27. </Result>
My current XSLT:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  3. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  4.     <xsl:strip-space elements="*" /> 
  5.     <xsl:template match="/">
  6.         <html>
  7.             <head><title>Dresses Per Price</title>
  8.             <link rel="stylesheet" type="text/css" href="price.css"/>
  9.             </head>
  10.             <body>
  11.                 <h3>Dresses Per Price Displayed</h3>
  12.                 <table border="1">
  13.                     <thead>
  14.                         <tr style="background-color:PaleGreen;"><th>Name</th><th>Price</th><th>Image</th></tr>
  15.                     </thead>
  16.                     <tbody>
  17.                         <xsl:for-each select="Result">
  18.                             <xsl:apply-templates>
  19.                                 <xsl:sort select="Name" data-type="text" order="ascending"/>
  20.                             </xsl:apply-templates>
  21.                         </xsl:for-each>
  22.                     </tbody>
  23.                 </table>
  24.                 <p><strong>Note:</strong>Data listed above may not reflect the current state</p>
  25.             </body>
  26.         </html>
  27.     </xsl:template>
  28.     <xsl:template match="DressPrice">
  29.         <xsl:variable name="cssClass">
  30.             <xsl:choose>
  31.                 <xsl:when test="position() mod 2 = 0">coloured</xsl:when>
  32.                 <xsl:otherwise>normal</xsl:otherwise>
  33.             </xsl:choose>
  34.         </xsl:variable>
  35.         <tr class="{$cssClass}">
  36.             <xsl:apply-templates select="Name"/>
  37.             <xsl:apply-templates select="Price"/>
  38.             <xsl:apply-templates select="Image"/>
  39.         </tr>
  40.     </xsl:template>
  41.     <xsl:template match="Name|Price|Image">
  42.         <td><xsl:value-of select="text()"/></td>
  43.     </xsl:template>
  44. </xsl:stylesheet>

Can someone please help me or point me in the right direction? Thanks
Apr 9 '15 #1
7 7082
8,658 Recognized Expert Moderator Expert
I want to display images using xslt. How can i do this? Not familliar with XSLT
that’s not an XSLT issue, it’s an HTML issue (because you generate HTML /1/).

to answer the question: use an <img> tag

/1/ it’s like PHP, that doesn’t display images either, it can only create the data for displaying an image.
Apr 9 '15 #2
4 New Member
Thank you but can you show me how to use the <img> tag? Should it be added in the xslt?
Apr 9 '15 #3
8,658 Recognized Expert Moderator Expert
where else do you create the HTML code?

about the img tag.
Apr 9 '15 #4
4 New Member
Any hint where to place it?
Apr 9 '15 #5
8,658 Recognized Expert Moderator Expert
in the Image template.

and, yes, that requires you to write a new template.
Apr 9 '15 #6
4 New Member
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="Image">
  2.         <xsl:variable name="img">
  3.         <td><img src="{$img}"></img></td>
  4.         </xsl:variable>
  5.     </xsl:template>
This is what i tried so far but i'm getting an error. What did i do wrong? And thanks for your precious time.
Apr 9 '15 #7
8,658 Recognized Expert Moderator Expert
What did i do wrong?
what does the error say?
Apr 9 '15 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Fred | last post by:
Not much expertise on XSLT and trying to understand it's uses when creating apps in VS.NET? If I wanted flexibility on the UI (View aspect of M.V.C.): - How does it compare with creating business components that can be consumed by WebForms, WinForms, mobile devices, etc? Is it even fair to compare the such technologies? - How about for...
by: Dafna m | last post by:
Please HELP 1. How can I display an array of images from diffrent types(jpeg, bmp..)(In C#) Can I also display video files?(In C#) *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
by: TaeHo Yoo | last post by:
Would anyone be able to tell me how to display images dynomically from the database? I am using dataset which contains supplier name and supplier images. I can display supplier name but supplier images. Supplier image field only contains file name (ie, "a.gif"). How to bind this image to the report Thanks a lot in advance *** Sent via...
by: John Do | last post by:
Hi, I want to store the path and the name of the images in a sql 2000 database and all the images in a folder named images. And then I want to display all the images in a datagrid. Does any one know how to do it? Thanks in advance Jonh
by: Angel Tsankov | last post by:
Hello! Is the following code illformed or does it yield undefined behaviour: class a {}; class b {
by: basavaraj koti | last post by:
I need to show image using xslt Below provided in my xml and xslt. <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type="text/xsl" href="../xyz.xsl"?> <Grade class="03" subject="Science"> <media id="2809"> <topic>A Bird's Paradise</topic> <category>Concept</category> <type>Animation</type>
by: Randy | last post by:
Hi, I have a small table - 2 columns, 5 rows. Col 1 is the key column and has integer values of 1 through 5. Column 2 is a varbinary(MAX) column and has jpg images loaded in it. What I want to is to bind a combobox to this table so that the combobox will display these these five images in its dropdown list and the user can then select...
by: Confused but working on it | last post by:
Just wanted to say thanks for the posts helping me make ths work. Added a few comments and after the readdir used a pattern match to test for ..jpg, and seems to work fine on my test setup. Maybe I should test for gif, tiff, and png... Anyway, here's the code: <?php //Open images directory $dir = opendir("images"); //read files in the dir...
by: saritha2008 | last post by:
Hi, I have to convert the following Input xml code to output xml code using xslt. Can any one please help on escaping single quotation present in the input xml file in my xslt? <resolution>Won'tFix</resolution>
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.