xsl-list
[Top] [All Lists]

Re: [xsl] XSL:FO - how to render a single footnote

2006-09-12 12:03:16
Hi Ken,
 
Thanks for your response.  I don't understand how to implement what
your'e suggesting.

This template rule matches footnote:

<xsl:template match="footnote">
          <xsl:if test="@opid">
                <fo:wrapper id="{(_at_)opid}" />
        </xsl:if>
        <fo:footnote>
            <fo:inline font-size="0.83em" baseline-shift="super">
                <xsl:number level="any" count="footnote" format="1"/>
            </fo:inline>
            <fo:footnote-body>
                <fo:list-block
provisional-distance-between-starts="20pt"
provisional-label-separation="5pt" start-indent="0.0in"
space-before="12pt">
                    <fo:list-item>
                        <fo:list-item-label end-indent="label-end()">
                            <fo:block
xsl:use-attribute-sets="standardFont" font-size="8pt">
                                <xsl:number level="any" count="footnote"
format="1)"/>
                            </fo:block>
                        </fo:list-item-label>
                        <fo:list-item-body start-indent="body-start()">
                            <fo:block
xsl:use-attribute-sets="standardFont" font-size="8pt">
                                <xsl:value-of select="@notetext"/>
                            </fo:block>
                        </fo:list-item-body>
                    </fo:list-item>
                </fo:list-block>
            </fo:footnote-body>
        </fo:footnote>
    </xsl:template>

This template rule matches xrefinline. When the toFootnote attribue is
set to yes, xrefinlne references a footnote. In that case, I want to
output the number of the footnote referenced by the targetid attribute
of the xrefinline element. 
This template counts all footnotes so the result is the total number of
footnotes in the document, not footnote number of the particular
footnote referenced by the targetid attribute:

  <xsl:template match="xrefinline">
                <xsl:choose>
                        <xsl:when test="@toFootnote='no'">
                        <fo:basic-link color="blue"
internal-destination="{(_at_)targetid}">
                                <xsl:value-of select="."/>
(<xsl:value-of select="$__Page_Token"/>
                        <fo:page-number-citation
ref-id="{(_at_)targetid}"/>)</fo:basic-link>
                        </xsl:when>
                <xsl:otherwise>
                            <xsl:number level="any" count="footnote"
format="1"/>
                </xsl:otherwise>
                </xsl:choose>
   </xsl:template>

Substituting this line outputs a 1 for each footnote because it counts
the number of footnotes whose opid equals fn_foo2.  What I want is to
count the number of the footnote with the fn_foo2 attribute.

<xsl:number level="any" count="footnote[(_at_)opid='fn_foo2']" format="1"/>

Thanks in advance for any suggestions.

Regards,

Ann Marie

------------------------------------------------------------------------
------------------------

Subject: Re: [xsl] XSL:FO - how to render a single footnote for
multiple, identical footnotes in
From: "G. Ken Holman" <gkholman(_at_)xxxxxxxxxxxxxxxxxxxx
<mailto:gkholman(_at_)DOMAIN(_dot_)HIDDEN> >
Date: Sun, 10 Sep 2006 20:45:08 -0400
        
At 2006-09-10 17:04 -0700, Ann Marie Rubin \(anrubin\) wrote: 

        Is there a way to output a single footnote for multiple,
identical XML
        footnote entries in pdf?
        


Yes, but in your XSLT work and not in your XSL-FO work.



        For example, a document that has 2 identical footnotes:
        
        
        foo <footnote notetext="footnote text" opid="fn1"/>
        bar <footnote notetext="footnote text" opid="fn1"/>

        outputs:
        
        
        foo1
        foo2
        ------------
        1. footnote text
        2. footnote text

        instead of:
        
        
        foo1
        bar1
        -------------
        1. footnote text

        I created an XML element that cross-references an existing,
identical
        footnote.

        <xref toFootnote="yes id="fn1"/>
        
        
        I want to write an XSL stylesheet that processes the
xreftoFootnote
        element by outputting the footnote number of the referenced
footnote.
        


Good ... then whatever algorithm you are using
for the footnote numbering you just use again for
the referenced footnote.  Remember that it is
your stylesheet that calculates and presents the
footnote in the first place, so you just have to do it every time you
need
it.


        I
        have the ID of the referenced footnote but can think of no way
to access
        the footnote number.
        


You can't "access" it, you have to recalculate it.



        Is there a way to save the footnote IDs and
        footnote numbers in memory so that the xreftoFootnote template
could
        retrieve the footnote number for a particular ID?
        


No ... but it is very common in XSLT to have to
recalculate things because of the
non-side-effect-freeness of the language.  You
might consider using a called template, perhaps
based on the current node, then when you present
the footnote it gets calculated with the current
node ... then when it comes time to use the
reference to the footnote, change your current
node to the referenced footnote, then just call
the template again and it is guaranteed to
calculate to the same value (that's the feature of
side-effect-freeness).

I hope this helps!

. . . . . . . . . . . . . Ken


--
UBL/XML/XSLT/XSL-FO training: Verx, Denmark 2006-10-02/06,11-20/24
UBL International 2006  2006-11-13/17 http://www.ublconference.com
<http://www.ublconference.com/> 
World-wide corporate, govt. & user group UBL, XSL, & XML training.
G. Ken Holman                 mailto:gkholman(_at_)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 Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>