This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: automatic generation of figure numbers


> 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]