Subject: RE: [xsl] "grouping" footnote numbers From: Emma Burrows <Emma.Burrows@xxxxxxxxxxx> Date: Tue, 11 Oct 2011 13:42:28 +0100 |
From: David Carlisle [mailto:davidc@xxxxxxxxx] > change that to xsl:value-of select="position()" having grouped them all > you just want to know which group you ar in and position(0 tells you that Thank you very much for looking into this. Alas, this XSL: <xsl:key name="fn" match="xref" use="@href"/> ... <sup> <xsl:for-each-group select="key('fn', @href)" group-by="@href"> <xsl:value-of select="position()"/> </xsl:for-each-group> </sup> Just results in every reference being numbered as 1. I'm not sure why - either because the grouping is based on a key or because this appears in the "xref" template? To move this forward, here is some actual XML for you: Input ===== <p><b>Caesarean section</b></p> <p>Single dose<xref href="footnote-113022.dita#bnf_113022" type="fn"/> of i/v cefuroxime</p> <p>Administer immediately after umbilical cord is clamped. Add i/v teicoplanin<xref href="footnote-202621.dita#bnf_202621" type="fn"/></p> <p><b>Hysterectomy</b><xref href="footnote-204127.dita#bnf_204127" type="fn"/></p> <p>Single dose<xref href="footnote-113022.dita#bnf_113022" type="fn"/> of i/v cefuroxime + i/v metronidazole<xref href="footnote-113019.dita#bnf_113019" type="fn"/> <i>or</i> i/v gentamicin + i/v metronidazole<xref href="footnote-113019.dita#bnf_113019" type="fn"/> <i>or</i> i/v co-amoxiclav alone</p> <p>Use single dose<xref href="footnote-113022.dita#bnf_113022" type="fn"/> of i/v gentamicin + i/v metronidazole<xref href="footnote-113019.dita#bnf_113019" type="fn"/> or add i/v teicoplanin<xref href="footnote-202621.dita#bnf_202621" type="fn"/></p> <p><b>Termination of pregnancy</b></p> <p>Single dose<xref href="footnote-113022.dita#bnf_113022" type="fn"/> of oral metronidazole</p> XSL: ==== <xsl:key name="fn" match="xref[@type='fn']" use="@href"/> <xsl:template match="p"> <xsl:element name="{local-name()}"><xsl:apply-templates/></xsl:element> </xsl:template> <xsl:template match="xref"> <a href="{@href}"> <sup> <xsl:for-each-group select="key('fn', @href)" group-by="@href"> <xsl:number level="any"/> </xsl:for-each-group> </sup> </a> </xsl:template> (Incorrect) Output: =================== <p>Caesarean section</p> <p>Single dose<a href="footnote-113022.dita#bnf_113022"><sup>1</sup></a> of i/v cefuroxime</p> <p>Administer immediately after umbilical cord is clamped. Add i/v teicoplanin<a href="footnote-202621.dita#bnf_202621"><sup>2</sup></a></p> <p>Hysterectomy<a href="footnote-204127.dita#bnf_204127"><sup>3</sup></a></p> <p>Single dose<a href="footnote-113022.dita#bnf_113022"><sup>1</sup></a> of i/v cefuroxime + i/v metronidazole<a href="footnote-113019.dita#bnf_113019"><sup>5</sup></a> or i/v gentamicin + i/v metronidazole<a href="footnote-113019.dita#bnf_113019"><sup>5</sup></a> or i/v co-amoxiclav alone</p> <p>Use single dose<a href="footnote-113022.dita#bnf_113022"><sup>1</sup></a> of i/v gentamicin + i/v metronidazole<a href="footnote-113019.dita#bnf_113019"><sup>5</sup></a> or add i/v teicoplanin<a href="footnote-202621.dita#bnf_202621"><sup>2</sup></a></p> <p>Termination of pregnancy</p> <p>Single dose<a href="footnote-113022.dita#bnf_113022"><sup>1</sup></a> of oral metronidazole</p> So essentially, I get footnote reference numbers 1, 2, 3 and 5. I'd like number 5 to come out as number 4 as I'd expect. Thank again, David, and whoever would like to jump in to give you a break. :)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] "grouping" footnote numbe, David Carlisle | Thread | Re: [xsl] "grouping" footnote numbe, Brandon Ibach |
Re: [xsl] "grouping" footnote numbe, David Carlisle | Date | Re: [xsl] Need XML grep-like tool f, Peter Flynn |
Month |