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] Generated Text numbering


Hi Scott:
The %n token is resolved by processing the element in mode="label.markup".
You will find in common/labels.xsl this template that does it:

<xsl:template match="figure|table|example|procedure" mode="label.markup">
  <xsl:variable name="pchap"
                select="ancestor::chapter
                        |ancestor::appendix
                        |ancestor::article[ancestor::book]"/>

  <xsl:variable name="prefix">
    <xsl:if test="count($pchap) &gt; 0">
      <xsl:apply-templates select="$pchap" mode="label.markup"/>
    </xsl:if>
  </xsl:variable>

  <xsl:choose>
    <xsl:when test="@label">
      <xsl:value-of select="@label"/>
    </xsl:when>
    <xsl:when test="local-name() = 'procedure' and
                    $formal.procedures = 0">
      <!-- No label -->
    </xsl:when>
    <xsl:otherwise>
      <xsl:choose>
        <xsl:when test="count($pchap)>0">
          <xsl:if test="$prefix != ''">
            <xsl:apply-templates select="$pchap" mode="label.markup"/>
            <xsl:apply-templates select="$pchap"
mode="intralabel.punctuation"/>
          </xsl:if>
          <xsl:number format="1" from="chapter|appendix" level="any"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:number format="1" from="book|article" level="any"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

This template handles the counting chore for all of the formal objects in
DocBook.  If you want to change the counting process for all of them, then
just copy this template to your customization layer and change this line:

        <xsl:when test="count($pchap)>0">
to:
        <xsl:when test="false()">

The template will then fall through to the xsl:otherwise clause, which
counts from the book element rather than the chapter element.

If you just want to change the behavior for tables, then you can cut down
the match attribute in the xsl:template element.

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net


----- Original Message ----- 
From: "scott" <scott.speights@o3sis.com>
To: <docbook-apps@lists.oasis-open.org>
Sent: Tuesday, May 24, 2005 7:58 AM
Subject: [docbook-apps] Generated Text numbering


> Hello All,
>
> I am currently working on finalizing the first draft of our first
> docbook document and the following questions have issue has occurred.
>
> - With the generated text for table titles the %n token in the generated
> text begins counting tables at each chapter.
>
> So with each new chapter, the first table title begins with Table 1 -
> <Title>
>
> Can anybody tell me how to get gentext for table titles to ouput table
> numbers sequentially for an entire document instead of starting over at
> each chapter?
>
> Many Thanks,
>
> Scott Speights
>
> O3SIS IT AG
> Email: scott.speights.o3sis.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
>
>
>



---------------------------------------------------------------------
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]