我有一个样式表,我接近有效但由于某种原因,我有多个“没有模板存在”和“xsl:with-param不能作为xsl:template的子项出现”消息出现。
整个文档中有一个主要的文档也无法编译。
这是xsl
<xsl:template match="calcScores">
<xsl:with-param name="currentRound" />
<xsl:with-param name="currentHole" />
<xsl:variable name="parTotal" select="sum(//par[@holeNumber <= @currentHole])" />
<xsl:variable name="golferTotal" select="sum(@currentRound/score[@holeNumber < currentHole])" /> <!-- look at <= here -->
<xsl:variable name="currentScore" select="parTotal - golferTotal" />
<xsl:variable name="currentScoreText" >
<xsl:call-template name="formatScore">
<xsl:with-param name="scoreValue" select="@currentScore"></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<td><xsl:value-of select="currentScoreText"/></td>
<xsl:choose>
<xsl:when test="currentHole=18">
<xsl:variable name="backNinePar" select="sum(//par[@holeNumber > 9 and @holeNumber < 18])"></xsl:variable>
<xsl:variable name="backNineGolfer" select="sum(@currentRound/score[@holeNumber > 9 and @holeNumber <= 18])"></xsl:variable>
<xsl:variable name="backNineScore." select="backNinePar - backNineGolfer"></xsl:variable>
<xsl:variable name="backNineScoreText" >
<xsl:call-template name="formatScore">
<xsl:with-param name="scoreValue" select="@backNineScore"></xsl:with-param>
</xsl:call-template>
</xsl:variable>
</xsl:when>
<xsl:when test="currentHole=9">
<td class="sub">$currentScoreText</td>
</xsl:when>
</xsl:choose>
<xsl:if test="@currentHole < 18">
<xsl:call-template name="calcScores">
<xsl:with-param name="currentRound" select="@currentRound"></xsl:with-param>
<xsl:with-param name="currentHole" select="@currentHole+1"></xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="formatHole">
<xsl:with-param name="holeScore" />
<xsl:choose>
<xsl:when test="@holeScore < @parScore" >
<td class="low">holeScore</td>
</xsl:when>
<xsl:when test="holeScore > parScore" >
<td class="high">holeScore</td>
</xsl:when>
<xsl:otherwise>
<td>holeScore</td>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
答案 0 :(得分:1)
部分
<xsl:template match="calcScores">
<xsl:with-param name="currentRound" />
<xsl:with-param name="currentHole" />
错了,需要
<xsl:template match="calcScores">
<xsl:param name="currentRound" />
<xsl:param name="currentHole" />
或者
<xsl:template name="calcScores">
<xsl:param name="currentRound" />
<xsl:param name="currentHole" />