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]

Counting the nesting level of an element


Hi,

I can't seem to be able to resolve this problem by myself: I'd just like to
count the nesting level of <sect> in my document, in order to affect the
result to HTML heading levels, so that I get h1, h2, etc...

 <xsl:template match="sect">
   <xsl:variable name="sect_nesting">
     <xsl:number level="any" count="?" format="1"/>
   </xsl:variable>
   <xsl:element name="h{$sect_nesting}">
     <xsl:apply-templates select="title/text()"/>
   </xsl:element>
   <xsl:apply-templates select="*[position() > 1]"/>
 </xsl:template>

I've tried dozens of patterns to fill the count attribute of <xsl:number>,
without being able to find the right combination of ancestors, descendants,
or selfs... Any clue out there?

Cheers,
-- 
Xavier.


 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]