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

RE: saving nodes for later output

Subject: RE: saving nodes for later output
From: "David Santamauro" <david.santamauro@xxxxxxxx>
Date: Sat, 3 Nov 2001 13:16:22 -0500
david elswhere 2001
excellent! I just added

<xsl:template match="text()" mode="table-footnotes"/>

and my problem disappeared.

Thanks for your help.

David

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Trevor Nash
Sent: Saturday, November 03, 2001 11:20
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  saving nodes for later output


David Santamauro wrote:

>I'm not sure how to go about this so here is my qeustion:
>
>I have markup which represents a table and inside the table are footnotes
>and footnote references. I want to save the footnotes (body) outside of the
>table.
>
You do not need to 'save' anything.  Use modes.
There are lots of variations on this technique, but for example:

When you match the table node <tab> do an <xsl:apply-templates/>
followed by <xsl:aply-templates mode="footnotes"/> .

Write templates with no mode attribute which produce the main HTML
table.  When you match the footnote-body bit, output nothing.

Write templates with mode="footnotes" which mostly just do another
apply-templates mode="footnotes".  When you match the footnote-body
bit, output it.

So you do not save anything at all, instead you traverse the input
document twice.  I know that isn't the way you would write a normal
program, but XSLT is not a normal programming language.

BTW I think your XML would be better expressed something like this:

<tab>
 <row>
  <cell id="1">Text with a footnote.<footnote
mark="*">This is the text referred to in cell
id="1"</footnote></cell>
  <cell id ="2">More text...</cell>
 </row>
 <row><cell id="3">&nbsp;</cell></row>
 <row><cell id="4">&nbsp;</cell></row>
</tab>

See how I have put the footnote text where its referenced: I let XSLT
do the work of moving it elswhere on output.  The templates in this
case would include:

<xsl:template match="footnote">
    <a href="#{generate-id()"><sup><xsl:value-of select="@mark"
/></sup></a>
</xsl:template>

<xsl:template match="footnote" mode="footnote">
    <p><a name="{generate-id()"><xsl:value-of select="@mark" /></a>
<xsl:value-of select="'" /></p>
</xsl:template>

Using generate-id() saves you having to put unique labels in the
original document.

If you have lots of footnotes you might want to put the selection of
the footnote mark in the XSLT too.

If you want one footnote to apply to more than one cell then you need
a cross reference, as in

<tab>
 <row>
  <cell id="1">Text with a footnote.<footnote
mark="*" id="x">This is the text referred to in cell
id="1" and "2"</footnote></cell>
  <cell id ="2">More text...<footnote-ref f.id="x"/></cell>
 </row>
 <row><cell id="3">&nbsp;</cell></row>
 <row><cell id="4">&nbsp;</cell></row>
</tab>

To get the '*' marker for a footnote-ref  just means doing what you do
for the footnote element with the matching id:

<xsl:key name="footnotes" match="footnote" use="@id" />
<xsl:template match="footnote-ref">
    <xsl:apply-templates select="key('footnotes', @f.id)" />
</xsl:template>

Regards,
Trevor Nash
--
Traditional training & distance learning,
Consultancy by email

Melvaig Software Engineering Limited
voice:     +44 (0) 1445 771 271
email:     tcn@xxxxxxxxxxxxx

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.