Css XSL样式表模板未生成正确的可视元素

Css XSL样式表模板未生成正确的可视元素,css,xml,xslt,Css,Xml,Xslt,在我的浏览器中查看XML文件(congress.XML)时,election.xsl中的drawCells模板似乎没有生成正确的可视元素。应该生成一个条形图,但实际上不是 在浏览器中打开congress.xml。在文本编辑器中打开elections.xsl 这些文件是 congress.xml election.xsl candidates.xml vwstyles.css vwlogo.png 这里是一个谷歌驱动器链接到所有的文件。。。 这是一幅应该发生的事情的图像 如果您认为可以通过查

在我的浏览器中查看XML文件(congress.XML)时,election.xsl中的drawCells模板似乎没有生成正确的可视元素。应该生成一个条形图,但实际上不是

在浏览器中打开congress.xml。在文本编辑器中打开elections.xsl

这些文件是

congress.xml
election.xsl
candidates.xml
vwstyles.css
vwlogo.png
这里是一个谷歌驱动器链接到所有的文件。。。

这是一幅应该发生的事情的图像

如果您认为可以通过查看election.xsl样式表itelself来了解为什么不会发生这种情况,那么这里就是

<?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="document('candidates.xml')/candidates/candidate[@candidateID]" />


   <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">
      <tr>

        <xsl:variable name="candidateVotes" select="sum(votes)" />
        <xsl:variable name="totalVotes" select="sum(..//votes)" />
        <xsl:variable name="candidatePercent" select="($candidateVotes) div ($totalVotes)" />
        <xsl:variable name="candidateName" select="$candidateInfo[@candidateID=current()/@candidateID]/name" />
        <xsl:variable name="candidateParty" select="$candidateInfo[@candidateID=current()/@candidateID]/party" />

        <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($candidatePercent, '#0.0%')" />)
        </th>

        <td>
            <xsl:call-template name="drawCells">
                <xsl:with-param name="cellCount" select="round(100 * $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>

明尼苏达州国会选举结果
明尼苏达州国会选举结果
地区
候选人
投票
()         
()

将对
drawcell
的调用包装在自己的
td
元素中,因此嵌套
td
s:

<td>
    <xsl:call-template name="drawCells">...</<xsl:call-template>
</td>


…将对
drawcell
的调用包装在自己的
td
元素中,因此嵌套
td
s:

<td>
    <xsl:call-template name="drawCells">...</<xsl:call-template>
</td>


…非常感谢!这就解决了。非常感谢!这就解决了问题。