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]
Other format: [Raw text]

count(ancestor::section) + 1


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


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