473,320 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

4
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"?>
  2.  
  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 7007
Dormilich
8,658 Expert Mod 8TB
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
Kathy
4
Thank you but can you show me how to use the <img> tag? Should it be added in the xslt?
Apr 9 '15 #3
Dormilich
8,658 Expert Mod 8TB
where else do you create the HTML code?

about the img tag.
Apr 9 '15 #4
Kathy
4
Any hint where to place it?
Apr 9 '15 #5
Dormilich
8,658 Expert Mod 8TB
in the Image template.

and, yes, that requires you to write a new template.
Apr 9 '15 #6
Kathy
4
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
Dormilich
8,658 Expert Mod 8TB
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

5
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...
3
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...
2
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...
2
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...
10
by: Angel Tsankov | last post by:
Hello! Is the following code illformed or does it yield undefined behaviour: class a {}; class b {
1
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"...
2
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...
9
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...
1
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? ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.