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

keys and generating footnotes

Subject: keys and generating footnotes
From: "Whitney, Dan \(CanWest Interactive\)" <DWhitney@xxxxxxxxxxx>
Date: Thu, 28 Jun 2007 23:16:07 -0500
 keys and generating footnotes
I have the following scenario and am having a lot of trouble getting it
to work. I've tried the usual places for a solution but with no luck.
I've tried switching the "match" and "use" attributes in the key to no
avail.

Here is my xml:

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="sample.xsl"?>

<publication>
  <table print="suppress">
    <tr>
      <td>table 1: row 1: column 1<fn idref="1">Works...Nothing is
generated</fn></td>
      <td>table 1: row 1: column 2<fn idref="1">Works...Nothing is
generated</fn></td>
      <td>table 1: row 1: column 3<fn idref="4">Works...Nothing is
generated</fn></td>
    </tr>
  </table>
  <table>
    <tr>
      <td>table 2: row 1: column 1<fn idref="1">Works...Should be
numbered 1 and generate a reference below output table 1 numbered 1 with
this text</fn></td>
      <td>table 2: row 1: column 2<fn idref="2">Works...Should be
numbered 2 and generate a reference below output table 1 numbered 2 with
this text</fn></td>
      <td>table 2: row 1: column 3<fn idref="1">Works...Should be
numbered 1 but not generate any text under output table 1</fn></td>
    </tr>
  </table>
  <table>
    <tr>
      <td>table 3: row 1: column 1<fn idref="1">Doesn't work...Should be
numbered 1 and generate a reference below output table 2 numbered 1 with
this other text</fn></td>
      <td>table 3: row 1: column 2</td>
      <td>table 3: row 1: column 3</td>
    </tr>
  </table>
</publication>

Here is my xsl:

<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:output
    method="html"
    indent="yes"
    encoding="iso-8859-1"
    version="4.0"/>

<xsl:key name="fnref" match="table[not(@print)]/tr/td/fn" use="@idref"/>

<xsl:template match="publication">
  <xsl:for-each select="table[not(@print)]">
    <table border="1">
      <xsl:for-each select="tr">
        <tr>
          <xsl:for-each select="td">
            <td>
              <xsl:value-of select="text()"/>
              <xsl:apply-templates mode="idref"
select="ancestor::tr/td/fn[@idref=current()/fn/@idref][generate-id()=gen
erate-id(key('fnref',@idref)[1])]"/>
            </td>
          </xsl:for-each>
        </tr>
      </xsl:for-each>
      <xsl:apply-templates mode="id"
select="tr/td/fn[generate-id()=generate-id(key('fnref',@idref)[1])]"/>
    </table>
  </xsl:for-each>
</xsl:template>

<xsl:template match="table[not(@print)]/tr/td/fn" mode="idref">
  <sup>
    <xsl:number
count="fn[generate-id()=generate-id(key('fnref',@idref)[1])]" format="1"
from="table" level="any"/>
  </sup>
</xsl:template>

<xsl:template match="fn" mode="id">
  <tr>
    <td colspan="3">
      <xsl:number
count="fn[generate-id()=generate-id(key('fnref',@idref)[1])]" format="1.
" from="table" level="any"/>
      <xsl:value-of select="."/>
    </td>
  </tr>
</xsl:template>
</xsl:stylesheet>

And here is the output I want:

<table border="1">
   <tr>
      <td>table 2: row 1: column 1<sup>1</sup></td>
      <td>table 2: row 1: column 2<sup>2</sup></td>
      <td>table 2: row 1: column 3<sup>1</sup></td>
   </tr>
   <tr>
      <td colspan="3">1. Works...Should be numbered 1 and generate a
reference below output table 1 numbered 1 with this text</td>
   </tr>
   <tr>
      <td colspan="3">2. Works...Should be numbered 2 and generate a
reference below output table 1 numbered 2 with this text</td>
   </tr>
</table>
<table border="1">
   <tr>
      <td>table 3: row 1: column 1</td>
      <td>table 3: row 1: column 2</td>
      <td>table 3: row 1: column 3</td>
   </tr>
<!-- the tr below and its content is not generated, but I want it to be:
   <tr>
      <td colspan="3">1. Doesn't work...Should be numbered 1 and
generate a reference below output table 2 numbered 1 with this other
text</td>
   </tr>
-->
</table>

How do I set up the key so it "refreshes" on every table element?

Thanks in advance for any forthcoming help.

Dan Whitney

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.