This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XSL List
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: Re: [xsl] XSL List
- From: "Nikolai Grigoriev" <grig at renderx dot com>
- Date: Sat, 26 May 2001 09:37:54 +0400
- References: <3.0.6.32.20010526043622.008f56d0@pop.algonet.se>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Gustaf,
> <!ELEMENT part (header, (part | p | codeblock | note | list |
> table | image)*)>
<skip/>
> First I thought that this structure would allow me to make something
> intelligent when it comes to styling the headers at different levels. After
> all, the FO attributes are all the same for different levels of headers,
> with the exception of font-size. The idea was to decrease only the size 4pt
> for each level, but I have since abandoned this idea, since it got too
> complicated. If you got a finished solution, I'm very interested though...
Well, the structure seems quite reasonable. You can put all common
attributes in a separate attribute set, and then use a standalone
template to add only those attributes that are level-dependent.
To get the level, you can use count(ancestor::part). The whole
thing would look like this:
<!-- Common attributes for titles - at top level -->
<xsl:attribute-set name="title-attrs">
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
<!-- whatever other attribute you like -->
</xsl:attribute-set>
<!-- Main template for headers -->
<xsl:template match="header">
<fo:block xsl:use-attribute-sets="title-attrs">
<!-- Generate attributes not included in the attribute-set -->
<xsl:call-template name="variable-title-attrs"/>
<!-- Generate text for the header -->
<xsl:number level="multiple" format="1.1.1.1.1.1." count="part"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<!-- Template that generates all level-dependent attributes -->
<xsl:template name="variable-title-attrs">
<xsl:variable name="level" select="count(ancestor::part)"/>
<xsl:attribute name="font-size">
<xsl:choose>
<xsl:when test="$level=1">30pt</xsl:when>
<xsl:when test="$level=2">24pt</xsl:when>
<xsl:when test="$level=3">20pt</xsl:when>
<xsl:when test="$level=4">16pt</xsl:when>
<xsl:when test="$level=5">13pt</xsl:when>
<xsl:otherwise>12pt</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:template>
Hope this helps.
Best regards,
Nikolai Grigoriev
RenderX
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list