Jump to content

Xml And Xslt


sugarplum19
 Share

Recommended Posts

Hi I need to put a image in a xml file and preview it in the browser but the image does not show also I am using a xslt file to sytle it.This is my codeXML <student> <student_id>12345677</student_id> <student_name>Ahmed Samir</student_name> <mark>66</mark> <photo>mickey.jpg</photo> </student>XSLT<img> <xsl:attribute name="scr"> <xsl:value-of select="photo"/> </xsl:attribute> </img>Any suggestions will be appreciated

Link to comment
Share on other sites

Regardless of whether you're generating a whole document or a fragment, you still need the xsl:stylesheet and at least one xsl:template. In your case, I think this should do it:

<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/student"><img><xsl:attribute name="scr"><xsl:value-of select="photo"/></xsl:attribute></img></xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

Yes I did that.This is my whole code<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/"> <html> <body> <table border="1"> <xsl:for-each select="modules/module"> <tr> <h3>Module Name:</h3> <td> <xsl:value-of select="module_name"/> </td> </tr> <tr> <h3>Module Code:</h3> <td> <xsl:value-of select="module_code"/> </td> </tr> <tr> <td> <h3>Student Name</h3> </td> <td> <h3>Student ID</h3> </td> <td> <h3>Student Mark</h3> </td> <td> <h3>Grade</h3> </td> <td> <h3>Photo</h3> </td> </tr> <xsl:for-each select="student"> <tr> <td> <xsl:value-of select="student_name"/> <xsl:text> </xsl:text> </td> <td> <xsl:value-of select="student_id"/> </td> <td> <xsl:value-of select="mark"/> </td> <xsl:choose> <xsl:when test="mark >=0 and mark <=39"> <td>F</td> </xsl:when> <xsl:when test="mark >=40 and mark <=49"> <td>D</td> </xsl:when> <xsl:when test="mark >=50 and mark <=59"> <td>C</td> </xsl:when> <xsl:when test="mark >=60 and mark <=69"> <td>B</td> </xsl:when> <xsl:when test="mark >=70 and mark <=100"> <td>A</td> </xsl:when> </xsl:choose> <td> <img> <xsl:attribute name="scr"> <xsl:value-of select="photo"/> </xsl:attribute> </img> </td> </tr> </xsl:for-each> </xsl:for-each></table> </body> </html> </xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...