-1
我想在循環中聲明一個外部變量。但它給我的錯誤 我的XSLT是 在其範圍外使用全局變量
<xsl:for-each select="document($kush_xml)">
<xsl:variable name="total_error" select="sum(vfiler/@error)"/>
<xsl:variable name="total_warning" select="sum(vfiler/@warning)"/>
<xsl:variable name="err_cnt">
<xsl:value-of select="count(document($precheck_cft_xml)/
kush/sevenmtt_cft/jobs/precheck_job/result_entries/
resultEntry[result/aptType='BLOCKING_ERROR' and
not(contains($filter_cft_codes,result/code)) and
result/aptType!='NEW_STEP' and
(result/affectedCommonResources/controllerName=$controller or
(not(result/affectedCommonResources/controllerName) and
(ancestor::precheck_job/@controller_a=$hostname or ancestor::precheck_job/@controller_b=$hostname)))])"/>
</xsl:variable>
<xsl:variable name="warn_cnt">
<xsl:value-of select="count(document($precheck_cft_xml)/
netapp/sevenmtt_cft/precheck_jobs/precheck_job/result_entries/
resultEntry[result/aptType='SERIOUS_WARNING' and
not(contains($filter_cft_codes,result/code)) and
result/aptType!='NEW_STEP' and
(result/affectedCommonResources/controllerName=$controller or
(not(result/affectedCommonResources/controllerName) and
(ancestor::precheck_job/@controller_a=$hostname or ancestor::precheck_job/@controller_b=$hostname)))])"/>
</xsl:variable>
我要計算表條目加入total_error and err_cnt
和total_warning and warn_cnt
什麼我的XML是
<chapter id="4.2.1" heading=" Feasibility">
<tbl>
<columns>
<c name="Controller"/>
<c name="Prechecks " align="center"/>
<c name="Prechecks Review" align="center"/>
</columns>
</tbl>
</chapter>
現在該怎麼辦我想要做的是warn_cnt
和err_cnt
在<for-each>
循環之外使用。因爲我必須根據這些值計算表中的值。不知何故,我無法在標籤中創建表格,因爲它創建了多個表格。所以我必須在循環外寫我的表代碼。 我試過的是在變量內使用<for:each>
循環,但它沒有幫助。 好心幫我
是我的嘗試是
<xsl:variable name="warn_cnt">
<xsl:for-each select="document($precheck_xml)/kush/sevenmtt/controller">
<xsl:value-of select="count(document($precheck_cft_xml)/
netapp/sevenmtt_cft/precheck_jobs/precheck_job/result_entries/
resultEntry[result/aptType='SERIOUS_WARNING' and
not(contains($filter_cft_codes,result/code)) and
result/aptType!='NEW_STEP' and
(result/affectedCommonResources/controllerName=$controller or
(not(result/affectedCommonResources/controllerName) and
(ancestor::precheck_job/@controller_a=$hostname or ancestor::precheck_job/@controller_b=$hostname)))])"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="err_cnt">
<xsl:for-each select="document($precheck_xml)/netapp/sevenmtt/controller">
<xsl:value-of select="count(document($precheck_cft_xml)/
kush/sevenmtt_cft/precheck_jobs/precheck_job/result_entries/
resultEntry[result/aptType='BLOCKING_ERROR' and
not(contains($filter_cft_codes,result/code)) and
result/aptType!='NEW_STEP' and
(result/affectedCommonResources/controllerName=$controller or
(not(result/affectedCommonResources/controllerName) and
(ancestor::precheck_job/@controller_a=$hostname or ancestor::precheck_job/@controller_b=$hostname)))])"/>
</xsl:for-each>
</xsl:variable>
,但是這是不工作的。
請不要發表相同的問題兩次 - 而是花時間和精力澄清你想要的東西。 –