This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: automatic generation of figure numbers
- To: "'xsl-list at mulberrytech dot com'" <xsl-list at mulberrytech dot com>
- Subject: RE: automatic generation of figure numbers
- From: Kay Michael <Michael dot Kay at icl dot com>
- Date: Wed, 4 Oct 2000 19:07:21 +0100
- Reply-To: xsl-list at mulberrytech dot com
> Mike Kay suggested (I am thankful to him for that) the following code:
>
> <xsl:template match="figure">
> <xsl:variable name="fig"><!--variable for the figure number-->
> <xsl:for-each select="//figure[@file=current()/@file][1]">
> <xsl:number level="any"
> count="figure[not(@file=preceding::file/@file)]"/>
> </xsl:for-each>
> </xsl:variable>
> <xsl:value-of select="$fig"/>
> </xsl:template>
>
> Also Mike, I am unable to follow logic of the code (which
> is entirely my shortcoming). Could you/anybody else explain
> it to me
I've made a couple of little corrections.
The xsl:variable statement first (in the for-each part) finds the first
<figure> in the document whose @file attribute is the same as the @file
value of the current <figure>. Then (in the xsl:number part) it assigns a
sequence number to this <figure>, getting its position among all those
<figure>s in the document whose @file attribute is not the same as the @file
attribute of some preceding figure. Then (in the xsl:value-of) it writes the
result to the output.
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list