I have been working on this XSL document that is required to use functional programming, and even though it is error-free, the result document is not rendering properly and looks like pages and pages of only numbers and no text (it looks like machine code.).
The result should display the candidate names, votes, percentage of votes, the district and a bar chart equal to the length of votes. I keep messing with it but nothing seems to change the appearance. Some parts that confuse me are:the Global Variable that references the "candidates/candidate" nodeset; the cellCount parameter that is equal to the value of the "candidatePercent" variable MULTIPLIED by 100 and rounded to the nearest integer; among other things.
Here is my code:
The XML doc (which was pre-made) is far too long, and basically just contains names and votes. Anyone please offer some guidance? Thank you.
<?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" doctype-system="about:legacy-compat" encoding="UTF-8" indent="yes" /><xsl:variable name="candidateInfo" select="/candidates/candidate" /><xsl:template match="/"><html><head><title>Minnesota Congressional Election Results</title><link href="vwstyles.css" rel="stylesheet" type="text/css" /></head><body><div id="wrap"><header><img src="vwlogo.png" alt="Voter Web" /></header><h1>Minnesota Congressional Election Results</h1><section id="votingResults"><xsl:apply-templates select="congressResults/district" /></section></div></body></html></xsl:template><xsl:template match="district"><h2>District <xsl:value-of select="@dNumber" /></h2><table class="electionTable"><thead><tr><th>Candidate</th><th>Votes</th></tr></thead><tbody><xsl:apply-templates select="candidates/candidate" /></tbody></table></xsl:template><xsl:template match="candidate"><xsl:variable name="candidateVotes" value-of="sum(votes)" /><xsl:variable name="totalVotes" value-of="sum(..//votes)" /><xsl:variable name="candidatePercent" select="sum($candidateVotes) div count($totalVotes)" /><xsl:variable name="candidateName" select="$candidateInfo[@candidateID=current()/@candidateID]/name" /><xsl:variable name="candidateParty" select="$candidateInfo[@candidateID=current()/@candidateID]/party" /><tr><th><xsl:value-of select="$candidateName" /> (<xsl:value-of select="$candidateParty" />)</th><th><xsl:value-of select="format-number($candidateVotes, '###,##0')" /> (<xsl:value-of select="format-number(ScandidatePercent, '#0.0%')" />)</th><td><xsl:call-template name="drawCells"><xsl:with-param name="cellCount" select="100 * round($candidatePercent)" /><xsl:with-param name="party" select="$candidateParty" /></xsl:call-template></td></tr></xsl:template><xsl:template name="drawCells"><xsl:param name="cellCount" /><xsl:param name="party" /><xsl:if test="$cellCount > 0"><td class="{$party}"></td><xsl:call-template name="drawCells"><xsl:with-param name="cellCount" select="$cellCount - 1" /><xsl:with-param name="party" select="$party" /></xsl:call-template></xsl:if></xsl:template></xsl:stylesheet>