我坚持使用继承的xslt模板,这会产生错误:
line 200: Variable or parameter 'child' is undefined.
问题是,此行或整个文件中没有任何其他变量或参数“child”。对“child”的唯一引用是在xpath中。 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>
答案 0 :(得分:1)
现在(2018年)我遇到了同样的错误。没有进口,而且线路非常相似。带错误的行就像这样
<xsl:with-param name="ancestor" select="$ancestor"/>
我将变量的名称更改为firstFather,错误消失了。
<xsl:with-param name="firstFather" select="$firstFather"/>
我认为祖先是一个保留名称,它在变量中使用时会失败。