-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>
,但是这是不工作的。
请不要发表相同的问题两次 - 而是花时间和精力澄清你想要的东西。 –