[xsl] count(ancestor::section) + 1

Subject: [xsl] count(ancestor::section) + 1
From: Gustaf Liljegren <gustafl@xxxxxxxxxx>
Date: Sat, 15 Jun 2002 15:08:49 +0200
Nikolai at RenderX once helped me with this smart template for choosing
font sizes on headers at different levels:

  <xsl:template name="header-font-size">
    <xsl:variable name="level" select="count(ancestor::section)"/>
    <xsl:attribute name="font-size">
      <xsl:choose>
        <xsl:when test="$level=1">18pt</xsl:when>
        <xsl:when test="$level=2">14pt</xsl:when>
        <xsl:when test="$level=3">10pt</xsl:when>
        <xsl:otherwise>10pt</xsl:otherwise>
      </xsl:choose>
    </xsl:attribute>
  </xsl:template>

Now I'm adopting a DTD with a special <chapter> element (previously the
chapter was a <section>), so I need to add 1 to the
count(ancestor::section) expression. But it won't work:

  count(ancestor::section) + 1

I've tried this too:

  count(ancestor::chapter) + count(ancestor::section)

I must be missing something...

Gustaf


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread