[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSL List

Subject: Re: XSL List
From: "Nikolai Grigoriev" <grig@xxxxxxxxxxx>
Date: Sat, 26 May 2001 09:37:54 +0400
xsl dependent level
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.