Given this 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>
This will be a table with the footnote number in a row and the footnote number and footnote in the table footer.
Desired output (except the footnotes are in a table footer):
| Name | Remarks |
|---|---|
| Bulb | 1 2 |
| small bulb | 2 |
| 1 Make sure the bulb works. | |
| 2 Make sure that the new bulb is not cracked. |
Actual output:
| Name | Remarks |
|---|---|
| Bulb | |
| small bulb | |
| 1 Make sure the bulb works. | |
| 2 Make sure that the new bulb is not cracked. |
The footnotes are displaying correctly in the footer, but xsl:number is not working in <footnoteRef> (it's blank)
This also works in <footnote> but not <footnoteRef>:
<xsl:number count="footnote" from="reqSpares"/>
I did not think I needed to be in <footnote> to count <footnote> with xsl:number
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>
CodePudding user response:
Your pattern count=reqSpares/descendant::footnote is counting footnote elements, but the context item is a footnoteref, so there aren't any footnote elements to be counted. You need to navigate to the footnote element. Note that in XSLT 3.0 you can do this using xsl:number/@select - you no longer need to reset the context item using xsl:for-each.
