Below provided in my xml and xslt.
Expand|Select|Wrap|Line Numbers
- <?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>
- <objectives>
- <list>To build a bird shelter or bird paradise
- </list>
- </objectives>
- <synopsis>
- <list>
- The animation introduces the child to build a secure and happy environment for birds.
- </list>
- </synopsis>
- </media>
- <media id="2863">
- <topic>A Good House</topic>
- <category>Concept</category>
- <type>Animation</type>
- <objectives>
- <list>To list out the parameters of a good house</list>
- </objectives>
- <synopsis>
- <list>
- The features of a good and comfortable house, whether large or small, are carefully explained with colourful illustrations to a child.</list>
- </synopsis>
- </media>
- </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
- <?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE xsl:stylesheet [
- <!ENTITY nbsp "*">
- <!ENTITY copy "©">
- <!ENTITY reg "®">
- <!ENTITY trade "™">
- <!ENTITY mdash "—">
- <!ENTITY ldquo "“">
- <!ENTITY rdquo "”">
- <!ENTITY pound "£">
- <!ENTITY yen "¥">
- <!ENTITY euro "€">
- ]>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <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"/>
- <xsl:template match="/">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
- <title>
- <xsl:for-each select="Grade">
- Class <xsl:value-of select="@class" /> <xsl:value-of select="@subject" />
- </xsl:for-each>
- </title>
- <style type="text/css">
- .hd
- {
- display:block;
- font-family:Arial, Helvetica, sans-serif;
- font-size:12pt;
- font-weight:bold;
- text-decoration:underline;
- text-align:center;
- color:#ff6600;
- }
- table.grey
- {
- border-left:#ccc 1px solid;
- border-top:#ccc 1px solid;
- }
- td.grey
- {
- border-right:#ccc 1px solid;
- border-bottom:#ccc 1px solid;
- font-family:Arial, Helvetica, sans-serif;
- font-size:10pt;
- font-weight:normal;
- text-decoration:none;
- padding:3px;
- }
- td p
- {
- font-family:Arial, Helvetica, sans-serif;
- font-size:10pt;
- text-align:left;
- }
- </style>
- </head>
- <body>
- <xsl:for-each select="Grade">
- <h4>
- <span class="hd">Class <xsl:value-of select="@class" /> <xsl:value-of select="@subject" /></span>
- </h4>
- </xsl:for-each>
- <xsl:for-each select="Grade">
- <xsl:variable name="cls" select="@class" />
- <xsl:variable name="subj" select="@subject" />
- <xsl:for-each select="media">
- <table width="100%" border="0" cellpadding="0" cellspacing="0" id="tbl1" class="grey">
- <tr>
- <td width="15%" class="grey"><b>Grade</b></td>
- <td width="20%" class="grey"><xsl:value-of select="$cls" /></td>
- <td width="65%" rowspan="6" class="grey">
- SHOW THE IMAGE HERE
- </td>
- </tr>
- <tr>
- <td class="grey"><b>Subject</b></td>
- <td class="grey"><xsl:value-of select="$subj" /></td>
- </tr>
- <tr>
- <td class="grey"><b>Topic</b></td>
- <td class="grey"><xsl:value-of select="topic" /></td>
- </tr>
- <tr>
- <td class="grey"><b>Category</b></td>
- <td class="grey"><xsl:value-of select="category" /></td>
- </tr>
- <tr>
- <td class="grey"><b>Media Type</b></td>
- <td class="grey"><xsl:value-of select="type" /></td>
- </tr>
- <tr>
- <td class="grey"><b>Media ID</b></td>
- <td class="grey"><xsl:value-of select="@id"></xsl:value-of></td>
- </tr>
- <tr>
- <td class="grey"><b>Learning Objective</b></td>
- <td colspan="2" class="grey">
- <xsl:value-of select="objectives" /> <br />
- </td>
- </tr>
- <tr>
- <td colspan="3" class="grey">
- <p><b>Synopsis</b></p>
- <p><xsl:value-of select="synopsis" /></p>
- </td>
- </tr>
- </table>
- <br />
- </xsl:for-each>
- </xsl:for-each>
- </body>
- </html>
- </xsl:template>
- </xsl:stylesheet>
Bkoti