Getting XML, XSL, and HTML to work
To begin, I'm using Adobe's Spry Framework for all my data in my XML
page, it saves space and code on the HTML. Well, I want to make it so
that certain cells are chosen and are either highlighted with green or
red depending on a condition.
====================================XML=========== ===========================
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="bowlgames.xsl"?>
<bowlgames>
<game id="1">
<name>Poinsetta Bowl</name>
<date>12/19/06 8:00 PM</date>
<channel>ESPN 2</channel>
<team1>TCU</team1>
<team2>Northern Illinois</team2>
<score>37-7</score>
<winner>TCU</winner>
<steve>TCU</steve>
<brandon>TCU</brandon>
</game>
<game id="2">
<name>Las Vegas Bowl</name>
<date>12/21/06 8:00 PM</date>
<channel>ESPN HD</channel>
<team1>BYU</team1>
<team2>Oregon</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>BYU</steve>
<brandon</brandon>
</game>
<game id="3">
<name>New Orleans Bowl</name>
<date>12/22/06 8:00 PM</date>
<channel>ESPN 2 HD</channel>
<team1>Rice</team1>
<team2>Troy</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Rice</steve>
<brandon</brandon>
</game>
<game id="4">
<name>Papajohns.com Bowl</name>
<date>12/23/06 1:00 PM</date>
<channel>ESPN 2 HD</channel>
<team1>South Florida</team1>
<team2>East Carolina</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>East Carolina</steve>
<brandon</brandon>
</game>
<game id="5">
<name>New Mexico Bowl</name>
<date>12/23/06 4:30 PM</date>
<channel>ESPN HD</channel>
<team1>New Mexico</team1>
<team2>San Jose State</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>San Jose State</steve>
<brandon</brandon>
</game>
<game id="6">
<name>Bell Helicopter Armed Forces Bowl</name>
<date>12/23/06 8:00 PM</date>
<channel>ESPN HD</channel>
<team1>Tulsa</team1>
<team2>Utah</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Tulsa</steve>
<brandon</brandon>
</game>
<game id="7">
<name>Hawaii Bowl</name>
<date>12/24/06 8:00 PM</date>
<channel>ESPN HD</channel>
<team1>Arizona State</team1>
<team2>Hawaii</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Arizona State</steve>
<brandon</brandon>
</game>
<game id="8">
<name>Motor City Bowl</name>
<date>12/26/06 7:30 PM</date>
<channel>ESPN HD</channel>
<team1>Middle Tennessee</team1>
<team2>Central Michigan</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Central Michigan</steve>
<brandon</brandon>
</game>
<game id="9">
<name>Emerald Bowl</name>
<date>12/27/06 8:00 PM</date>
<channel>ESPN HD</channel>
<team1>Florida State</team1>
<team2>UCLA</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>UCLA?</steve>
<brandon</brandon>
</game>
<game id="10">
<name>Independence Bowl</name>
<date>12/28/06 4:30 PM</date>
<channel>ESPN HD</channel>
<team1>Oklahoma State</team1>
<team2>Alabama</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Oklahoma State</steve>
<brandon</brandon>
</game>
<game id="11">
<name>Holiday Bowl</name>
<date>12/28/06 8:00 PM</date>
<channel>ESPN HD</channel>
<team1>California</team1>
<team2>Texas A&M</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>California</steve>
<brandon</brandon>
</game>
<game id="12">
<name>Texas Bowl</name>
<date>12/28/06 8:00 PM</date>
<channel>NFL Network</channel>
<team1>Rutgers</team1>
<team2>Kansas State</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Rutgers</steve>
<brandon</brandon>
</game>
<game id="13">
<name>Music CityBowl</name>
<date>12/29/06 1:00 PM</date>
<channel>ESPN HD</channel>
<team1>Clemson</team1>
<team2>Kentucky</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Clemson</steve>
<brandon</brandon>
</game>
<game id="14">
<name>Brut Sun Bowl</name>
<date>12/29/06 2:00 PM</date>
<channel>CBS</channel>
<team1>Oregon State</team1>
<team2>Missouri</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Missouri?</steve>
<brandon</brandon>
</game>
<game id="15">
<name>Liberty Bowl</name>
<date>12/29/06 4:30 PM</date>
<channel>ESPN HD</channel>
<team1>Houston</team1>
<team2>South Carolina</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>South Carolina</steve>
<brandon</brandon>
</game>
<game id="16">
<name>Insight Bowl</name>
<date>12/29/06 7:30 PM</date>
<channel>NFL Network</channel>
<team1>Texas Tech</team1>
<team2>Minnesota</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Minnesota</steve>
<brandon</brandon>
</game>
<game id="17">
<name>Champs Sports Bowl</name>
<date>12/29/06 8:00 PM</date>
<channel>ESPN HD</channel>
<team1>Purdue</team1>
<team2>Maryland</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Purdue</steve>
<brandon</brandon>
</game>
<game id="18">
<name>Meineke Car Care Bowl</name>
<date>12/30/06 1:00 PM</date>
<channel>ESPN HD</channel>
<team1>Navy</team1>
<team2>Boston College</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Navy</steve>
<brandon</brandon>
</game>
<game id="19">
<name>Alamo Bowl</name>
<date>12/30/06 4:30 PM</date>
<channel>ESPN HD</channel>
<team1>Texas</team1>
<team2>Iowa</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Texas</steve>
<brandon</brandon>
</game>
<game id="20">
<name>Chick-fil-A Bowl</name>
<date>12/30/06 8:00 PM</date>
<channel>ESPN HD</channel>
<team1>Georgia</team1>
<team2>Virginia Tech</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Virginia Tech</steve>
<brandon</brandon>
</game>
<game id="21">
<name>MPC Computers Bowl</name>
<date>12/31/06 7:30 PM</date>
<channel>ESPN HD</channel>
<team1>Miami</team1>
<team2>Nevada</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Miami?</steve>
<brandon</brandon>
</game>
<game id="22">
<name>Outback Bowl</name>
<date>1/1/07 11:00 AM</date>
<channel>ESPN HD</channel>
<team1>Tennessee</team1>
<team2>Penn State</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Tennessee</steve>
<brandon</brandon>
</game>
<game id="23">
<name>Cotton Bowl</name>
<date>1/1/07 11:30 AM</date>
<channel>FOX</channel>
<team1>Auburn</team1>
<team2>Nebraska</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Nebraska?</steve>
<brandon</brandon>
</game>
<game id="24">
<name>Gator Bowl</name>
<date>1/1/07 1:00 PM</date>
<channel>CBS</channel>
<team1>West Virginia</team1>
<team2>Georgia Tech</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>West Virginia</steve>
<brandon</brandon>
</game>
<game id="25">
<name>Capital One Bowl</name>
<date>1/1/07 1:00 PM</date>
<channel>ABC HD</channel>
<team1>Arkansas</team1>
<team2>Wisconsin</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Wisconsin</steve>
<brandon</brandon>
</game>
<game id="26">
<name>Rose Bowl</name>
<date>1/1/07 5:00 PM</date>
<channel>ABC HD</channel>
<team1>USC</team1>
<team2>Michigan</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Michigan</steve>
<brandon</brandon>
</game>
<game id="27">
<name>Fiesta Bowl</name>
<date>1/1/07 8:00 PM</date>
<channel>FOX</channel>
<team1>Boise State</team1>
<team2>Oklahoma</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Oklahoma</steve>
<brandon</brandon>
</game>
<game id="28">
<name>Orange Bowl</name>
<date>1/2/07 8:00 PM</date>
<channel>FOX</channel>
<team1>Louisville</team1>
<team2>Wake Forest</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Louisville</steve>
<brandon</brandon>
</game>
<game id="29">
<name>Sugar Bowl</name>
<date>1/3/07 8:00 PM</date>
<channel>FOX</channel>
<team1>Notre Dame</team1>
<team2>LSU</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>LSU</steve>
<brandon</brandon>
</game>
<game id="30">
<name>International Bowl</name>
<date>1/6/07 8:00 PM</date>
<channel>ESPN2 HD</channel>
<team1>Cincinnati</team1>
<team2>Western Michigan</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Cincinnati</steve>
<brandon</brandon>
</game>
<game id="31">
<name>GMAC Bowl</name>
<date>1/7/07 8:00 PM</date>
<channel>ESPN HD</channel>
<team1>Ohio</team1>
<team2>Southern Miss</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Southern Miss</steve>
<brandon</brandon>
</game>
<game id="32">
<name>BCS Championship Game</name>
<date>1/8/07 8:00 PM</date>
<channel>FOX</channel>
<team1>Florida</team1>
<team2>Ohio State</team2>
<score>N/A</score>
<winner>N/A</winner>
<steve>Ohio State</steve>
<brandon</brandon>
</game>
</bowlgames>
========================================XSL======= ============================
<?xml version="1.0" encoding="ISO-8859-1"?><!--
DWXMLSource="bowlgames.xml" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:spry="http://ns.adobe.com/spry/">
<xsl:template match="/">
<xsl:for-each select="bowlgames/game">
<div align="left" class="ContentMain" style="position:absolute;
left:144px; top:398px; z-index:3; width: 697px;"
spry:region="dsBowlGame" >
<table width="100%" border="1" cellpadding="1" cellspacing="0"
bordercolor="#000000" align="center">
<tr>
<th width="3%" onclick="dsBowlGame.sort('@id');">#</th>
<th onclick="dsBowlGame.sort('steve');">Steve's Pick</th>
<th onclick="dsBowlGame.sort('brandon');">Brandon's Pick</th>
</tr>
<tr spry:repeat="dsBowlGame">
<td align="center">{@id}</td>
<xsl:choose>
<xsl:when test="bowlgames/game/steve = bowlgames/game/winner">
<td align="center"><span
style="color:#00FF00">{steve}</span></td>
</xsl:when>
<xsl:otherwise>
<td align="center"><span
style="color:#FF0000">{steve}</span></td>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="bowlgames/game/brandon =
bowlgames/game/winner">
<td align="center"><span
style="color:#00FF00">{brandon}</span></td>
</xsl:when>
<xsl:otherwise>
<td align="center"><span
style="color:#FF0000">{brandon}</span></td>
</xsl:otherwise>
</xsl:choose>
</tr>
</table>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
===================================HTML=========== ==========================
This is only a code snippet of the whole HTML file, because the XML
doesn't affect anyone else.
<div align="left" class="ContentMain" style="position:absolute;
left:144px; top:398px; z-index:3; width: 697px;"
spry:region="dsBowlGame" >
<table width="100%" border="1" cellpadding="1" cellspacing="0"
bordercolor="#000000" align="center">
<tr>
<th width="3%" onclick="dsBowlGame.sort('@id');">#</th>
<th width="25%" onclick="dsBowlGame.sort('name');">Bowl Name</th>
<th width="15%" onclick="dsBowlGame.sort('date');">Date &
Time</th>
<th width="10%"
onclick="dsBowlGame.sort('channel');">Channel</th>
<th width="13%" onclick="dsBowlGame.sort('team1');">Team 1</th>
<th width="13%" onclick="dsBowlGame.sort('team2');">Team 2</th>
<th width="10%" onclick="dsBowlGame.sort('score');">Score</th>
<th width="8%" onclick="dsBowlGame.sort('winner');">Winner</th>
<!--<th onclick="dsBowlGame.sort('steve');">Steve's Pick</th>
<th onclick="dsBowlGame.sort('brandon');">Brandon's Pick</th>-->
</tr>
<tr spry:repeat="dsBowlGame">
<td align="center">{@id}</td>
<td align="center">{name}</td>
<td align="center">{date}</td>
<td align="center">{channel}</td>
<td align="center">{team1}</td>
<td align="center">{team2}</td>
<td align="center">{score}</td>
<td align="center">{winner}</td>
<!--<td align="center">{steve}</td>
<td align="center">{brandon}</td>-->
</tr>
</table>
</div>
Any suggestions, help, what not is greatly appreciated! |