This is the mail archive of the docbook-apps@lists.oasis-open.org 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]

Re: [docbook-apps] Separating Numbers and Titles


Hi,

On Tuesday 10 May 2005 23:36, Bob Stayton wrote:
> [...]
>
> You can do this in a customization of the template named
> 'section.heading' in fo/sections.xsl. Don't use the $title parameter
> that is provided to that template, because it contains the result of
> processing in
> mode="object.title.markup", which combines the label and the title in
> one string.  You could compute the indent width as some multiple of the
> section level, which is available in the $level parameter passed to the
> template.

Thanks Bob, I figured it out already. I modified the "section.heading" 
template as you recommended. One problem was, where to introduce the 
"section.title.level*.properties" attribute sets. I checked the $level  
parameter for this and saved some objects (like title, label and a list 
fragment) into temporary variables which I use later. Here is my solution 
which can probably improved:


-------------------------------------------------------
<xsl:template name="section.heading">
  <xsl:param name="level" select="1"/>
  <xsl:param name="marker" select="1"/>
  <xsl:param name="title"/>
  <xsl:param name="titleabbrev"/>

  <xsl:variable name="_label">
   <xsl:apply-templates select="parent::*[1]" mode="label.markup"/>
  </xsl:variable>

  <xsl:variable name="_title">
   <xsl:apply-templates select="." mode="title.markup"/>
  </xsl:variable>

  <xsl:variable name="_list">
   <fo:list-item>
      <fo:list-item-label end-indent="label-end()">
         <fo:block><xsl:copy-of select="$_label"/></fo:block>
      </fo:list-item-label>
      <fo:list-item-body start-indent="body-start()">
         <fo:block><xsl:copy-of select="$_title"/></fo:block>
      </fo:list-item-body>
   </fo:list-item>
  </xsl:variable>

<!--
  <xsl:message>
    name  = <xsl:value-of select="name()"/>
    test  = "<xsl:value-of select="$_label=''"/>"
    level = "<xsl:value-of select="$level"/>"
    label = "<xsl:value-of select="$_label"/>"
    title = "<xsl:value-of select="$_title"/>"
  </xsl:message>
-->

  <xsl:choose>
   <xsl:when test="$_label=''">
      <xsl:apply-imports/><!-- Use original template -->
   </xsl:when>
   <xsl:otherwise>
    <xsl:choose>
      <xsl:when test="$level=1">
        <fo:block xsl:use-attribute-sets="section.title.properties
        section.title.level1.properties">
         <fo:list-block 
            provisional-distance-between-starts="2.5em"
            provisional-label-separation="1em">
          <xsl:copy-of select="$_list"/>
         </fo:list-block>
        </fo:block>
      </xsl:when>
      <xsl:when test="$level=2">
        <fo:block 
          xsl:use-attribute-sets="section.title.properties
                                  section.title.level2.properties">
         <fo:list-block 
            provisional-distance-between-starts="3em"
            provisional-label-separation="1em">
          <xsl:copy-of select="$_list"/>
         </fo:list-block>
        </fo:block>
      </xsl:when>
      <xsl:when test="$level=3">
        <fo:block 
          xsl:use-attribute-sets="section.title.properties
                                  section.title.level3.properties">
         <fo:list-block 
            provisional-label-separation="1em">
          <xsl:copy-of select="$_list"/>
         </fo:list-block>
        </fo:block>
      </xsl:when>
      <xsl:when test="$level=4">
        <fo:block 
           xsl:use-attribute-sets="section.title.properties
                                   section.title.level4.properties">
         <fo:list-block
            provisional-label-separation="1em">
          <xsl:copy-of select="$_list"/>
         </fo:list-block>
        </fo:block>
      </xsl:when>
      <xsl:when test="$level=5">
        <fo:block 
           xsl:use-attribute-sets="section.title.properties
                                   section.title.level5.properties">
         <fo:list-block 
            provisional-label-separation="1em">
          <xsl:copy-of select="$_list"/>
         </fo:list-block>
        </fo:block>
      </xsl:when>
      <xsl:otherwise>
        <fo:block 
           xsl:use-attribute-sets="section.title.properties
                                   section.title.level6.properties">
         <fo:list-block
            provisional-label-separation="1em">
          <xsl:copy-of select="$_list"/>
         </fo:list-block>
        </fo:block>
      </xsl:otherwise>
    </xsl:choose>
   </xsl:otherwise>
  </xsl:choose>
</xsl:template>
-------------------------------------------------------

As far as I know, there is no better solution of inserting attribute sets 
that depends of the $level parameter, right?

One deficiency is the absense of the $marker parameter and the layout of 
the list could be improved. I would like to have a distance between label 
and title of 1em without worrying about label width. So I inserted 
the provisional-* attributes, but I am not sure. It's sometimes a bit 
difficult with all the possible attributes to get a good looking list. :)

Thanks,
Tom

-- 
Thomas Schraitle

---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org


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