[英]Numbering table footnotes XSLT 3.0 with xsl:number xsl-fo
鉴于此 XML:
<reqSpares>
<spareDescrGroup>
<spareDescr>
<name>Bulb</name>
<footnoteRemarks>
<footnoteRef internalRefId="ftn-0001"/>
<footnoteRef internalRefId="ftn-0002"/>
</footnoteRemarks>
</spareDescr>
<spareDescr>
<embeddedSpareDescr>
<name>small bulb</name>
<footnoteRemarks>
<footnoteRef internalRefId="ftn-0002"/>
</footnoteRemarks>
</embeddedSpareDescr>
</spareDescr>
<footnote id="ftn-0001">
<para>Make sure the bulb works.</para>
</footnote>
<footnote id="ftn-0002">
<para>Make sure that the new bulb is not cracked.</para>
</footnote>
<spareDescrGroup>
</reqSpares>
这将是一个表格,其脚注编号在一行中,脚注编号和脚注在表格页脚中。
所需的 output(除了脚注在表页脚中):
姓名 | 评论 |
---|---|
电灯泡 | 1 2 |
小灯泡 | 2 |
1 确保灯泡正常工作。 | |
2 确保新灯泡没有破裂。 |
实际 output:
姓名 | 评论 |
---|---|
电灯泡 | |
小灯泡 | |
1 确保灯泡正常工作。 | |
2 确保新灯泡没有破裂。 |
脚注在页脚中正确显示,但xsl:number
在<footnoteRef>
中不起作用(它是空白的)
这也适用于<footnote>
但不适用于<footnoteRef>
:
<xsl:number count="footnote" from="reqSpares"/>
我认为我不需要在<footnote>
> 中使用xsl:number
来计算<footnote>
XSLT:
<xsl:param name="footnote-count-pattern" static="yes" as="xs:string" select="'reqSpares/descendant::footnote'"/>
<xsl:template match="footnoteRemarks">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="footnote">
<fo:block font-size="75%">
<xsl:number _count="{$footnote-count-pattern}" level="any"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="footnoteRef">
<!-- only need footnote number here -->
<fo:inline baseline-shift="super" font-size="75%">
<xsl:number _count="{$footnote-count-pattern}" level="any"/>
<xsl:text> </xsl:text>
</fo:inline>
</xsl:template>
<xsl:template match="reqSpares">
<fo:table>
<fo:table-column/>
<fo:table-column/>
<fo:table-header>
<fo:table-row>
<fo:table-cell>
<fo:block>Name</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>Remarks</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-footer>
<fo:table-row>
<fo:table-cell number-columns-spanned="2">
<fo:block>
<xsl:apply-templates select="descendant::footnote"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-footer>
<fo:table-body>
<xsl:apply-templates/>
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template match="spareDescr">
<fo:table-row>
<fo:table-cell>
<fo:block>
<xsl:apply-templates select="name"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:apply-templates select="footnoteRemarks"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
您的模式count=reqSpares/descendant::footnote
正在计算footnote
元素,但上下文项是footnoteref
,因此没有要计算的footnote
元素。 您需要导航到脚注元素。 请注意,在 XSLT 3.0 中,您可以使用xsl:number/@select
执行此操作 - 您不再需要使用xsl:for-each
重置上下文项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.