|
Subject: Re: [xsl] Extract footnotes From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sat, 03 Nov 2007 10:12:03 -0400 |
Can anybody let me know how to extract "footnote" from paragraph and write it to end of the section.
Below is what I am trying to do
Input
<section>
<para>111...<footnote label="1" id="f1"><para>First fnt</para></footnote> 222... <footnote label="2" id="f2"><para>second fnt</para></footnote> </para>
<para>333...<footnote label="3" id="f3"><para>Third fnt</para></footnote> ...</para>
</section>
Required Output <level> <para>111....222 .... </para> <para>333... ...</para> <footnote label="1" id="f1"><para>First fnt</para></footnote> <footnote label="2" id="f2"><para>second fnt</para></footnote> <footnote label="3" id="f3"><para>Third fnt</para></footnote> </level>
<xsl:template match="section"> <level> <xsl:apply-templates/> <xsl:if test="descendant::*[self::footnote]"> <xsl:apply-templates select="descendant::*[self::section//footnote]"/> </xsl:if> </level> </xsl:template>
<xsl:template match="para"> <xsl:copy> <xsl:apply-templates select="descendant::*[not(self::footnote)]"/> </xsl:copy> </xsl:template>
t:\ftemp>type rawat.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="section">
<level>
<!--do the body of the section-->
<xsl:apply-templates/>
<!--do the end notes for the section-->
<xsl:apply-templates select=".//footnote" mode="end-notes"/>
</level>
</xsl:template><xsl:template match="footnote"> <!--do nothing when first encountered--> </xsl:template>
<xsl:template match="footnote" mode="end-notes">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template><xsl:template match="@*|node()"><!--identity for all other nodes-->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template></xsl:stylesheet> t:\ftemp>xslt rawat.xml rawat.xsl con <?xml version="1.0" encoding="utf-8"?> <level>
<footnote label="1" id="f1">
<para>First fnt</para>
</footnote>
<footnote label="2" id="f2">
<para>second fnt</para>
</footnote>
<footnote label="3" id="f3">
<para>Third fnt</para>
</footnote>
</level>
t:\ftemp>-- Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008 World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Extract footnotes, J. S. Rawat | Thread | Re: [xsl] Extract footnotes, J. S. Rawat |
| RE: [xsl] first question to the lis, Michael Kay | Date | Re: [xsl] remove shape="rect" attri, B. Kamer |
| Month |