Subject: RE: [xsl] saving nodes for later output From: "David Santamauro" <david.santamauro@xxxxxxxx> Date: Sat, 3 Nov 2001 13:16:22 -0500 |
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: [xsl] 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"> </cell></row> <row><cell id="4"> </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"> </cell></row> <row><cell id="4"> </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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] saving nodes for later ou, David Santamauro | Thread | [xsl] [ANN] The interpreter of the , korlyukov |
RE: [xsl] saving nodes for later ou, David Santamauro | Date | [xsl] [ANN] The interpreter of the , korlyukov |
Month |