OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] Nested Sections From Block to Inline


On 10/10/06, Bob Stayton <bobs@sagehill.net> wrote:
> Hi Keith,
> Take a look in titlepage.templates.xsl.  That's the stylesheet module
> generated from the titlepage spec file, and it also adds fo:blocks.

Ah, of course! I somehow managed to convince myself that that was
_not_ the place yesterday...

I've now got exactly what I was looking for with the sect4/title, that
is, it's wrapped in an fo:inline. My next issue is how to get that
fo:inline inside the following fo:block.

Let's pretend the markup is:

<section id="4th-level">
  <title>HeadD</title>
  <para>The quick brown...</para>
  ...

Here's what I'm currently generating:
<fo:block id="section-wrapper">
  <fo:inline font="bar">
    <fo:inline>Head</fo:inline>
  </fo:inline>
  <fo:block font="foo">The quick brown...
   ...

Suggestions on how to move the fo:inline inside the fo:block?

My current best guess is to match sect4/*[2], but I don't know how to
ensure normal processing of that thing (<para>, in this case) once
I've done an
  <xsl:apply-templates select="title" mode="grabme"/>
(since I have no idea whether it'll be a <para> or a <orderedlist> or whatever).

Also, the problem compounds when I need to match section/*[2] but
check if it's $level = 4.

Ideas?

---------------------------------
For the record, here's how I got rid of all of the fo:blocks on my way
to having run-in 4th-level heads (the nested <section>s being the
annoying part). Similar, but simpler changes need to be made to the
sect4 templates...

[note: just snippets, not well-formed]:

 sections.xsl:

<xsl:template match="section/title
                     |simplesect/title
                     |sect1/title
                     |sect2/title
                     |sect3/title
                     |sect4/title
                     |sect5/title"
              mode="titlepage.mode"
              priority="2">
  <!-- pull _all_ of the variable defs up here -->
    <xsl:choose>
    <xsl:when test="$level = 4">
      <xsl:call-template name="section.heading">
        <xsl:with-param name="level" select="$level"/>
        <xsl:with-param name="title" select="$title"/>
        <xsl:with-param name="marker" select="$marker"/>
        <xsl:with-param name="titleabbrev" select="$titleabbrev.elem"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <!-- all the regular stuff -->

  <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:choose>
      <xsl:when test="$level = 4">
        <!-- interesting part here -->
        <fo:inline
xsl:use-attribute-sets="section.title.level4.properties
orm.section.level4.properties">
          <fo:marker marker-class-name="section.head.marker">
            <xsl:choose>
              <xsl:when test="$titleabbrev = ''">
                <xsl:value-of select="$title"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="$titleabbrev"/>
              </xsl:otherwise>
            </xsl:choose>
          </fo:marker>
          <xsl:copy-of select="$title"/>
          <!-- my trailing punctuation... -->
          <xsl:text>.</xsl:text>
        </fo:inline>
      </xsl:when>
      <xsl:otherwise>
        <!-- regular stuff here -->

 titlepage.templates.xsl:
    <xsl:template name="sect4.titlepage.recto">
    <xsl:choose>
      <xsl:when test="sect4info/title">
        <xsl:apply-templates mode="sect4.titlepage.recto.auto.mode"
select="sect4info/title"/>
      </xsl:when>
      <xsl:when test="info/title">
        <xsl:apply-templates mode="sect4.titlepage.recto.auto.mode"
select="info/title"/>
      </xsl:when>
      <!-- not yet!
      <xsl:when test="title">
        <xsl:apply-templates mode="sect4.titlepage.recto.auto.mode"
select="title"/>
      </xsl:when>
      -->
      <!-- rest is normal -->

  <xsl:template name="section.titlepage">
    <xsl:variable name="renderas">
      <xsl:choose>
        <xsl:when test="@renderas = 'sect1'">1</xsl:when>
        <xsl:when test="@renderas = 'sect2'">2</xsl:when>
        <xsl:when test="@renderas = 'sect3'">3</xsl:when>
        <xsl:when test="@renderas = 'sect4'">4</xsl:when>
        <xsl:when test="@renderas = 'sect5'">5</xsl:when>
        <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="level">
      <xsl:choose>
        <xsl:when test="$renderas != ''">
          <xsl:value-of select="$renderas"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="section.level"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="$level = 4">
        <xsl:variable name="recto.content">
          <xsl:call-template name="section.titlepage.before.recto"/>
          <xsl:call-template name="section.titlepage.recto"/>
        </xsl:variable>
        <xsl:variable name="recto.elements.count">
          <xsl:choose>
            <xsl:when
test="function-available('exsl:node-set')"><xsl:value-of
select="count(exsl:node-set($recto.content)/*)"/></xsl:when>
            <xsl:otherwise>1</xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:if test="(normalize-space($recto.content) != '') or
($recto.elements.count &gt; 0)">
          <xsl:copy-of select="$recto.content"/>
        </xsl:if>
        <xsl:variable name="verso.content">
          <xsl:call-template name="section.titlepage.before.verso"/>
          <xsl:call-template name="section.titlepage.verso"/>
        </xsl:variable>
        <xsl:variable name="verso.elements.count">
          <xsl:choose>
            <xsl:when
test="function-available('exsl:node-set')"><xsl:value-of
select="count(exsl:node-set($verso.content)/*)"/></xsl:when>
            <xsl:otherwise>1</xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:if test="(normalize-space($verso.content) != '') or
($verso.elements.count &gt; 0)">
          <xsl:copy-of select="$verso.content"/>
        </xsl:if>
        <xsl:call-template name="section.titlepage.separator"/>
      </xsl:when>
      <xsl:otherwise>
      <!-- normal stuff -->

  <xsl:template match="title" mode="section.titlepage.recto.auto.mode">
    <xsl:variable name="renderas">
      <xsl:choose>
        <xsl:when test="../@renderas = 'sect1'">1</xsl:when>
        <xsl:when test="../@renderas = 'sect2'">2</xsl:when>
        <xsl:when test="../@renderas = 'sect3'">3</xsl:when>
        <xsl:when test="../@renderas = 'sect4'">4</xsl:when>
        <xsl:when test="../@renderas = 'sect5'">5</xsl:when>
        <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="level">
      <xsl:choose>
        <xsl:when test="$renderas != ''">
          <xsl:value-of select="$renderas"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="section.level">
            <xsl:with-param name="node" select=".."/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="$level = 4">
        <!-- dunno if I should do nested inlines or not... -->
        <fo:inline xmlns:fo="http://www.w3.org/1999/XSL/Format";
xsl:use-attribute-sets="section.titlepage.recto.style"
margin-left="{$title.mar
          <xsl:apply-templates select="." mode="section.titlepage.recto.mode"/>
        </fo:inline>
      </xsl:when>
      <xsl:otherwise>
        <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format";
xsl:use-attribute-sets="section.titlepage.recto.style"
margin-left="{$title.marg
          <xsl:apply-templates select="." mode="section.titlepage.recto.mode"/>
        </fo:block>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


HTH,
Keith


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]