I was previously using XSLT 2.0 for this but decided to make it XSLT 1.0 compatible for certain reasons and from what I've read/found out, variables don't work in XPATH expressions in XSLT 1.0.
This was the original XSL that I used in XSLT 2.0:
<xsl:template match="footnote_ref">
<xsl:variable as="xs:integer" name="ref" select="."/>
<xsl:variable name="fid" select="generate-id(../following-sibling::footnote_list[1]/footnote[$ref])"/>
<sup><a href="#{$fid}">
<xsl:value-of select="."/>
</a></sup>
</xsl:template>
For citation n it will link to the nth footnote in the next footnote section.
In XSLT 1.0 this doesn't work, it seems to ignore the [$ref] part and just link to the first footnote regardless. I thought that dyn:evaluate from EXSLT would work so I tried:
<xsl:variable name="fid" select="dyn:evaluate('generate-id(../following-sibling::footnote_list[1]/footnote[$ref])')"/>
If I understand correctly, this should evaluate to generate-id(../following-sibling::footnote_list[1]/footnote[$ref]) but with $ref substituted. In the example they show using variables just fine but this still doesn't work and behaves just like without the dyn:evaluate, ignoring the variable entirely.
Am I doing something wrong or misunderstanding dyn:evaluate? If it matters I'm using libxslt through lxml (Python).