我堅持與繼承的XSLT模板,這會產生一個錯誤:XSL變量或參數是不確定的,但不是在文件
line 200: Variable or parameter 'child' is undefined.
的問題是,不存在變量或參數「子」在此行或其他任何在整個文件中。對「子」的唯一引用是在xpath中。 Line 200看起來像這樣:
<xsl:with-param name="ancestor"><xsl:value-of select="$ancestor"/></xsl:with-param>
這裏是我認爲是相關的整個部分。
<xsl:template name="create_title_row">
<xsl:param name="ancestor"/>
<xsl:param name="columnDepth"/>
<xsl:param name="pos"/>
<xsl:if test="$ancestor < $columnDepth">
<tr>
<xsl:for-each select="/mask/table[position()=$pos]/descendant::clmn[count(ancestor::clmn) = $ancestor]">
<xsl:call-template name="create_column">
<xsl:with-param name="ancestor"><xsl:value-of select="$ancestor"/></xsl:with-param>
<xsl:with-param name="columnDepth"><xsl:value-of select="$columnDepth"/></xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</tr>
<xsl:call-template name="create_title_row">
<xsl:with-param name="ancestor" select="$ancestor + 1"/>
<xsl:with-param name="columnDepth" select="$columnDepth"/>
<xsl:with-param name="pos" select="$pos"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="create_column">
<xsl:param name="ancestor"/>
<xsl:param name="columnDepth"/>
<xsl:variable name="for_export"><xsl:value-of select="/mask/@for_export"/></xsl:variable>
<xsl:variable name="depth">
<xsl:for-each select="descendant::clmn[not(child::clmn)]">
<xsl:sort select="count(ancestor::clmn)"/>
<xsl:if test="position()=last()">
<xsl:value-of select="count(ancestor::clmn)"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="rowspan">
<xsl:if test="$depth= ''">
<xsl:value-of select="$columnDepth - $ancestor"/>
</xsl:if>
<xsl:if test="$depth!= ''">1</xsl:if>
</xsl:variable>
<xsl:variable name="abstand">
<xsl:if test="$ancestor!=0 or position()!=1">0</xsl:if>
<xsl:if test="$ancestor=0 and position()=1">1</xsl:if>
</xsl:variable>
<xsl:variable name="cs">
<xsl:if test="$depth= ''">
<xsl:value-of select="@colspan"/>
</xsl:if>
<xsl:if test="$depth!= ''">
<xsl:value-of select="sum(descendant::clmn[not(child::clmn)]/@colspan)"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="colspan">
<xsl:if test="$cs!=0">
<xsl:value-of select="$cs + $abstand"/>
</xsl:if>
<xsl:if test="$cs=0">
<xsl:value-of select="1 + $abstand"/>
</xsl:if>
</xsl:variable>
<td class="column_title">
<xsl:if test="$rowspan>'1'">
<xsl:attribute name="rowspan"><xsl:value-of select="$rowspan"/></xsl:attribute>
</xsl:if>
<xsl:if test="$colspan>'1'">
<xsl:attribute name="colspan"><xsl:value-of select="$colspan"/></xsl:attribute>
</xsl:if>
<xsl:if test="$for_export='0'">
<xsl:if test="string-length(@link)=0">
<xsl:value-of select="@title"/>
<xsl:text disable-output-escaping="yes">&nbsp;&nbsp;</xsl:text>
</xsl:if>
<xsl:if test="string-length(@link)!=0">
<xsl:if test="string-length(@desc)!=0">
<xsl:value-of select="@title"/>
<xsl:text disable-output-escaping="yes">&nbsp;&nbsp;</xsl:text>
<a class="mask_top" href="javascript:;" onclick="return(getOnlineHelp('{@link}'));" onmouseover="return(setzeStatus('{@desc}'));" onmouseout="return(setzeStatus(''));">
<xsl:value-of select="@desc"/>
</a>
</xsl:if>
<xsl:if test="string-length(@desc)=0">
<a class="mask_top" href="javascript:;" onclick="return(getOnlineHelp('{@link}'));" onmouseover="return(setzeStatus('{@title}'));" onmouseout="return(setzeStatus(''));">
<xsl:value-of select="@title"/>
</a>
</xsl:if>
</xsl:if>
</xsl:if>
<xsl:if test="$for_export='1'">
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:value-of select="@title"/>
</xsl:if>
<xsl:if test="string-length(@comment)!=0">
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
<sup><xsl:value-of select="@comment"/></sup>
</xsl:if>
</td>
</xsl:template>
首先想到的是,它可能不是指該文件中的第200行。是否有任何可能引用不同xsl文件的xsl:import/xsl:include指令? – Flynn1179
第200行不在您展示的模板之內,對嗎?所以,在這些模板的層面上(不在裏面),必須有變量'ancestor'的定義。你可以分享嗎? –
說出您正在使用哪個XSLT處理器很有用。您可能會發現某人在這裏熟悉其隱含的錯誤消息。您也可以嘗試通過不同的處理器運行樣式表,以查看是否可以獲得更好的診斷。 –