[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: "grouping" footnote numbers

Subject: RE: "grouping" footnote numbers
From: Emma Burrows <Emma.Burrows@xxxxxxxxxxx>
Date: Tue, 11 Oct 2011 13:42:28 +0100
RE:  "grouping" footnote numbers
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.