2013-11-27 10 views
0

我堅持與繼承的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 &lt; $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">&amp;nbsp;&amp;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">&amp;nbsp;&amp;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">&amp;nbsp;</xsl:text>   
     <xsl:value-of select="@title"/> 
    </xsl:if>   
    <xsl:if test="string-length(@comment)!=0"> 
     <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>   
     <sup><xsl:value-of select="@comment"/></sup> 
    </xsl:if> 
    </td> 
</xsl:template> 
+0

首先想到的是,它可能不是指該文件中的第200行。是否有任何可能引用不同xsl文件的xsl:import/xsl:include指令? – Flynn1179

+0

第200行不在您展示的模板之內,對嗎?所以,在這些模板的層面上(不在裏面),必須有變量'ancestor'的定義。你可以分享嗎? –

+0

說出您正在使用哪個XSLT處理器很有用。您可能會發現某人在這裏熟悉其隱含的錯誤消息。您也可以嘗試通過不同的處理器運行樣式表,以查看是否可以獲得更好的診斷。 –

回答

1

現在(2018)我被困在相同的錯誤。沒有進口,和這條線非常相似。錯誤的行是這樣的

<xsl:with-param name="ancestor" select="$ancestor"/> 

我將變量的名稱更改爲firstFather並且錯誤消失。

<xsl:with-param name="firstFather" select="$firstFather"/> 

我認爲祖先是一個保留名稱,它在變量中使用時失敗。

+0

這並沒有真正回答這個問題。如果您有不同的問題,可以通過單擊[提問](https://stackoverflow.com/questions/ask)來提問。您可以[添加賞金](https://stackoverflow.com/help/privileges/set-bounties)在您擁有足夠的[聲譽](https://stackoverflow.com/help/)後引起對此問題的更多關注什麼聲譽)。 - [來自評論](/ review/low-quality-posts/18888851) – JimHawkins