Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 16th, 2009, 02:15 AM
Registered User
 
Join Date: Jul 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT Creation

Basically, I'm trying to create a grade book view for my site which contains the XML data. I want to list the assignments (AssignmentDescription) in a column and have the User ID to the Left, just like the HTML i pasted. What am i doing wrong with my XLST sheet.


<html dir="ltr">
<head runat="server">
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled 1</title>
<meta name="Microsoft Theme" content="Lichen 1011, default">
</head>
<body>
<form id="form1" runat="server">
</form>
<table style="width: 100%">
<tr>
<td>&nbsp;</td>
<td>Assignment 1 from DB</td>
<td>Assignment 2 from DB</td>
<td>Assignment 3 from DB</td>
<td>Assignment 4 from DB</td>
<td>Total Score</td>
</tr>
<tr>
<td>John Smith</td>
<td>21</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Joe Dumars</td>
<td>58</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

</table>
</body>
</html>

XSLT

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<!--<font face="Arial, Helvetica, sans-serif" size="3">Announcements</font>-->
<table border="0" width="100%" cellpadding="4" cellspacing="1">
<tr height="50"><xsl:for-each select="NewDataSet/Data">
<xsl:choose>
<xsl:when test="node()">
<td width="150" bgcolor="#FAF9E4"><br/><xsl:value-of select="AssignmentDescription"/>
</td>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each> </tr>
<xsl:for-each select="NewDataSet/Data">
<tr height="50">
<xsl:choose>
<xsl:when test="node()">
<td width="25" bgcolor="#CCCCCC" ><br/><b><xsl:value-of select="StudentUID"/></b></td>

<td width="25" bgcolor="#F7B182" valign="top"><br/><xsl:value-of select="StudentPointsEarned"/></td>
<td width="25" bgcolor="#F7B182" valign="top"><br/><xsl:value-of select="StudentEarnedEC"/></td>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


XML Fil e

<NewDataSet>
- <Data>
<StudentUID>9996766666</StudentUID>
<FaculytRemarks>Did great</FaculytRemarks>
<CategoryDescription>Class Participation</CategoryDescription>
<CategoryWeight>10.0000</CategoryWeight>
<AssignmentDescription>Participation</AssignmentDescription>
<AssignmentPoints>10.0000</AssignmentPoints>
<AssignmentEC>0.0000</AssignmentEC>
<AssignmentTotal>10.0000</AssignmentTotal>
<StudentPointsEarned>45.00</StudentPointsEarned>
<StudentEarnedEC>2</StudentEarnedEC>
<StudentWeightedScore>6.714290</StudentWeightedScore>
</Data>
- <Data>
<StudentUID>9996766666</StudentUID>
<FaculytRemarks>Horrible job.</FaculytRemarks>
<CategoryDescription>Class Participation</CategoryDescription>
<CategoryWeight>10.0000</CategoryWeight>
<AssignmentDescription>Ch. 4 Team Time</AssignmentDescription>
<AssignmentPoints>10.0000</AssignmentPoints>
<AssignmentEC>0.0000</AssignmentEC>
<AssignmentTotal>10.0000</AssignmentTotal>
<StudentPointsEarned>31.00</StudentPointsEarned>
<StudentEarnedEC>3</StudentEarnedEC>
<StudentWeightedScore>4.857140</StudentWeightedScore>
</Data>
- <Data>
<StudentUID>99967633666</StudentUID>
<FaculytRemarks>Enter Faculty Remarks</FaculytRemarks>
<CategoryDescription>Class Participation</CategoryDescription>
<CategoryWeight>10.0000</CategoryWeight>
<AssignmentDescription>Ch. 7 Buzz Word and Self-Test</AssignmentDescription>
<AssignmentPoints>10.0000</AssignmentPoints>
<AssignmentEC>0.0000</AssignmentEC>
<AssignmentTotal>10.0000</AssignmentTotal>
<StudentPointsEarned>9.00</StudentPointsEarned>
<StudentEarnedEC>1</StudentEarnedEC>
<StudentWeightedScore>1.428570</StudentWeightedScore>
</Data>
- <Data>
 
Old July 16th, 2009, 05:20 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

I'm not clear on your question. But from some assumption, I have pasted the below code. Check and let me know if you have any doubts:

Code:
<xsl:template match="/">
<html>
<body>
<!--<font face="Arial, Helvetica, sans-serif" size="3">Announcements</font>-->
<table border="0" width="100%" cellpadding="4" cellspacing="1">
<xsl:for-each select="NewDataSet/Data">
<tr height="50">
<td width="150" bgcolor="#FAF9E4"><br/><xsl:value-of select="AssignmentDescription"/></td>
<td width="25" bgcolor="#CCCCCC"><br/><b><xsl:value-of select="StudentUID"/></b></td>
<td width="25" bgcolor="#F7B182" valign="top"><br/><xsl:value-of select="StudentPointsEarned"/></td> 
<td width="25" bgcolor="#F7B182" valign="top"><br/><xsl:value-of select="StudentEarnedEC"/></td> 
</tr>
</xsl:for-each> 
</table>
</body>
</html>
</xsl:template>

__________________
Rummy
 
Old July 16th, 2009, 01:57 PM
Registered User
 
Join Date: Jul 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT Modifications

Actually, what I wanted was for it to look like the following HTML code. If you can tweak the XSLT code to generate an HTML page like below. That's what I am looking for. Copy the html below into notepad and save as HTML, and that's what i am looking for.


<html dir="ltr">

<head runat="server">
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled 1</title>
<meta name="Microsoft Theme" content="Lichen 1011, default">
<style type="text/css">
.style1 {
color: #FFFFFF;
background-color: #008000;
}
.style2 {
border-style: solid;
border-width: 1px;
}
</style>
</head>

<body>

<form id="form1" runat="server">
</form>
<table style="width: 100%" class="style2">
<tr>
<td class="style1" style="width: 147px">&nbsp;</td>
<td class="style1"><strong>Assignment 1 from DB</strong></td>
<td class="style1"><strong>Assignment 2 from DB</strong></td>
<td class="style1"><strong>Assignment 3 from DB</strong></td>
<td class="style1"><strong>Assignment 4 from DB</strong></td>
<td class="style1"><strong>Total Score</strong></td>
</tr>
<tr>
<td style="width: 147px">John Smith</td>
<td>21</td>
<td>34</td>
<td>11</td>
<td>&nbsp;</td>
<td>89%</td>
</tr>
<tr>
<td style="width: 147px">Joe Dumars</td>
<td>58</td>
<td>21</td>
<td>22</td>
<td>&nbsp;</td>
<td>24%</td>
</tr>
<tr>
<td style="width: 147px">Henry Jonhs</td>
<td>21</td>
<td>89</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>

</body>

</html>
 
Old July 17th, 2009, 12:31 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

If you need an xslt script for the output you posted, you should post the relevant input xml. How could anyone code without knowing the tags in the input xml file?
__________________
Rummy





Similar Threads
Thread Thread Starter Forum Replies Last Post
Interface creation pratik28 ASP.NET 2.0 Basics 1 May 8th, 2009 08:08 AM
Table creation sunny227 XSLT 3 November 14th, 2007 02:50 PM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM
regarding tables creation in xslt barsha XSLT 0 September 28th, 2005 07:50 AM
Image Creation canibus Classic ASP Basics 1 November 4th, 2003 03:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.