源XML:
*
XSLT:
<COVER_DETAIL>
<COVERDETAILS>
<COVERNAME>AAA</COVERNAME>
<EFFECTIVEDATE>2010-04-30</EFFECTIVEDATE>
<EXPIRYDATE>2022-03-31</EXPIRYDATE>
<COVERAMOUNT/>
<COVERPERCENT/>
<COVERCODE>60</COVERCODE>
</COVERDETAILS>
<COVERDETAILS>
<COVERNAME>BBB</COVERNAME>
<EFFECTIVEDATE>2010-04-30</EFFECTIVEDATE>
<EXPIRYDATE>2022-03-31</EXPIRYDATE>
<COVERAMOUNT/>
<COVERPERCENT/>
<COVERCODE>60</COVERCODE>
</COVERDETAILS>
<COVERDETAILS>
<COVERNAME>CCC</COVERNAME>
<EFFECTIVEDATE>2022-04-01</EFFECTIVEDATE>
<EXPIRYDATE>2032-03-31</EXPIRYDATE>
<COVERAMOUNT/>
<COVERPERCENT>100</COVERPERCENT>
<COVERCODE>62</COVERCODE>
</COVERDETAILS>
<COVERDETAILS>
<COVERNAME>DDD</COVERNAME>
<EFFECTIVEDATE>2022-04-01</EFFECTIVEDATE>
<EXPIRYDATE>2032-03-31</EXPIRYDATE>
<COVERAMOUNT/>
<COVERPERCENT/>
<COVERCODE>85</COVERCODE>
</COVERDETAILS>
</COVER_DETAIL>
如何将<xsl:template name="COVERDETAILS">
<xsl:variable name="i" select="position()" />
<fo:table-row>
<fo:table-cell>
<fo:block>
<xsl:value-of select="$i"/>
<xsl:text>. </xsl:text>
<xsl:value-of select="COVERNAME"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block> --- Here i want to display percentage </fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
coverpercent
的{{1}}值应用于每个模板的所有其他封面的covercode
值。我希望将62
coverpercent
封面与coverpecent
covercode
应用于每个封面。
答案 0 :(得分:1)
您可以将变量定义为:
<xsl:variable name="perc" select="/COVER_DETAIL/COVERDETAILS[COVERCODE='62']/COVERPERCENT" />
然后在模板中使用此变量,您希望在其中显示百分比:
<xsl:value-of select="$perc"/>