473,406 Members | 2,698 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,406 software developers and data experts.

Show image using xslt in html page

I need to show image using xslt
Below provided in my xml and xslt.
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <?xml-stylesheet type="text/xsl" href="../xyz.xsl"?>
  3. <Grade class="03" subject="Science">
  4.     <media id="2809">
  5.         <topic>A Bird's Paradise</topic>
  6.         <category>Concept</category>
  7.         <type>Animation</type>
  8.         <objectives>            
  9.             <list>To build a bird shelter or bird paradise 
  10.             </list>
  11.         </objectives>
  12.         <synopsis>
  13.             <list> 
  14.             The animation introduces the child to build a secure and happy environment for birds.
  15.             </list>
  16.         </synopsis>
  17.     </media>
  18.     <media id="2863">
  19.         <topic>A Good House</topic>
  20.         <category>Concept</category>
  21.         <type>Animation</type>
  22.         <objectives>            
  23. <list>To list out the parameters of a good house</list>
  24.         </objectives>
  25.         <synopsis>
  26. <list> 
  27. The features of a good and comfortable house, whether large or small, are carefully explained with colourful illustrations to a child.</list>
  28.         </synopsis>
  29.     </media>
  30. </Grade>
========
Using the media id, i need to select the image with the same id(filename) from images folder and display it. Below is the xslt code.
==========
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE xsl:stylesheet  [
  2.     <!ENTITY nbsp   "*">
  3.     <!ENTITY copy   "©">
  4.     <!ENTITY reg    "®">
  5.     <!ENTITY trade  "™">
  6.     <!ENTITY mdash  "—">
  7.     <!ENTITY ldquo  "“">
  8.     <!ENTITY rdquo  "”"> 
  9.     <!ENTITY pound  "£">
  10.     <!ENTITY yen    "¥">
  11.     <!ENTITY euro   "€">
  12. ]>
  13. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  14. <xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
  15. <xsl:template match="/">
  16. <html xmlns="http://www.w3.org/1999/xhtml">
  17. <head>
  18. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
  19. <title>
  20.     <xsl:for-each select="Grade">
  21.         Class <xsl:value-of select="@class" />&nbsp;<xsl:value-of select="@subject" />
  22.     </xsl:for-each>
  23. </title>
  24. <style type="text/css">
  25. .hd
  26. {
  27.     display:block;
  28.     font-family:Arial, Helvetica, sans-serif;
  29.     font-size:12pt;
  30.     font-weight:bold;
  31.     text-decoration:underline;
  32.     text-align:center;
  33.     color:#ff6600;
  34. }
  35. table.grey
  36. {
  37.     border-left:#ccc 1px solid;
  38.     border-top:#ccc 1px solid;
  39. }
  40. td.grey
  41. {
  42.     border-right:#ccc 1px solid;
  43.     border-bottom:#ccc 1px solid;
  44.     font-family:Arial, Helvetica, sans-serif;
  45.     font-size:10pt;
  46.     font-weight:normal;
  47.     text-decoration:none;
  48.     padding:3px;
  49. }
  50. td p
  51. {
  52.     font-family:Arial, Helvetica, sans-serif;
  53.     font-size:10pt;
  54.     text-align:left;
  55. }
  56.  
  57. </style>
  58. </head>
  59. <body>
  60.     <xsl:for-each select="Grade">
  61.     <h4>
  62.         <span class="hd">Class <xsl:value-of select="@class" />&nbsp;<xsl:value-of select="@subject" /></span>
  63.     </h4>
  64.     </xsl:for-each>
  65.     <xsl:for-each select="Grade">
  66.         <xsl:variable name="cls" select="@class" />
  67.         <xsl:variable name="subj" select="@subject" />
  68.     <xsl:for-each select="media">
  69.     <table width="100%" border="0" cellpadding="0" cellspacing="0" id="tbl1" class="grey">
  70.         <tr>
  71.             <td width="15%" class="grey"><b>Grade</b></td>
  72.             <td width="20%" class="grey"><xsl:value-of select="$cls" /></td>
  73.             <td width="65%" rowspan="6" class="grey">
  74.                 SHOW THE IMAGE HERE
  75.             </td>
  76.         </tr>
  77.         <tr>
  78.             <td class="grey"><b>Subject</b></td>
  79.             <td class="grey"><xsl:value-of select="$subj" /></td>
  80.         </tr>
  81.         <tr>
  82.             <td class="grey"><b>Topic</b></td>
  83.             <td class="grey"><xsl:value-of select="topic" /></td>
  84.         </tr>
  85.         <tr>
  86.             <td class="grey"><b>Category</b></td>
  87.             <td class="grey"><xsl:value-of select="category" /></td>
  88.         </tr>
  89.         <tr>
  90.             <td class="grey"><b>Media Type</b></td>
  91.             <td class="grey"><xsl:value-of select="type" /></td>
  92.         </tr>
  93.         <tr>
  94.             <td class="grey"><b>Media ID</b></td>
  95.             <td class="grey"><xsl:value-of select="@id"></xsl:value-of></td>
  96.         </tr>
  97.         <tr>
  98.             <td class="grey"><b>Learning Objective</b></td>
  99.             <td colspan="2" class="grey">
  100.                 <xsl:value-of select="objectives" /> <br />
  101.             </td>
  102.         </tr>
  103.         <tr>
  104.             <td colspan="3" class="grey">
  105.                 <p><b>Synopsis</b></p>
  106.                 <p><xsl:value-of select="synopsis" /></p>
  107.             </td>
  108.         </tr>
  109.     </table>
  110.     <br />
  111.     </xsl:for-each>
  112.     </xsl:for-each>
  113. </body>
  114. </html>
  115. </xsl:template>
  116.  
  117. </xsl:stylesheet>
Thanks and Regards
Bkoti
May 24 '07 #1
1 4905
dorinbogdan
839 Expert 512MB
Hi,

Did you succeed to solve your problem?
If not, please let me know.
If yes, feel free to share it, to help other members with similar questions.

Thanks,
Dorin.
May 29 '07 #2

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

Similar topics

5
by: Al Davis | last post by:
Note: I tried cross-posting this message to several newsgoups, including comp.lang.perl.misc, c.l.p.moderated, comp.infosystems.www.authoring.cgi, comp.lang.javascript and comp.lang.php. Nothing...
9
by: Maurizio Penna | last post by:
I, guys. I've embeded an image into a xml file, something like that: <display type="picture" mime="image/png" name = "mosaico6.png"> <!]> </display> Now, I want to display it with a XSL...
4
by: Pat | last post by:
Is anyone using XML instead of HTML for pages of content? If so is there a public site to browse? Can someone point me to a discussion of the pros and cons of doing this? I am trying to get a...
2
by: Larry Marburger | last post by:
I've built and XSLT that is used to generate a simple TreeView-type, web-based control (ASP.NET / C#). When the tree is fully transformed (client-side, JavaScript transformation), there are about...
10
by: Raghavendra RAV | last post by:
Hi, I need to store an image from a Graphics object(.NET) inside a xml data island. Anyone might have came accross or have an idea how to do this. Please share. Thanks & Regards, Raghu, CSS...
2
by: J Sahoo | last post by:
Hi, I have a browse page where I am showing few fields from my SQL Server table. One of the field is Image type, all the fields are bound to a single table. I want to show the image from the...
2
by: Scamjunk | last post by:
I have been desperately looking for a treeview-type solution for my problem for the past three weeks and have been greatly unsuccessful. I am totally new to the world of XSLT and I *don't know*...
1
by: Arun dudee | last post by:
how to put img in xslt file where path of imge is present in xml not my pat of xml is <root> <img> <banner ban="C:/Documents and Settings/Administrator/Desktop/hariom/ xml/b.GIF"></banner>...
6
by: kadykedar | last post by:
Hi, I want to display Image using XSLT My XML is as follow <casestudy> <Company> <companylogo>http://www.microsoft.com/casestudies/resources/Logos/4000000140.gif</companylogo> </Company>...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...

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.