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] Changing chapter title to include chapter id


Hi Paulo,
I wasn't clear from your mail whether "I'm stuck at 1)" meant it worked and
you couldn't get past it, or that it didn't work.  In my testing, it worked,
so I presume you mean you need 2 and 3.

You can achieve the second item by putting the %n back into the gentext
template, and changing the template that generates the number.  The number
is generated by apply-templates in mode="label.markup".   I have an example
below.

For the third item, you can make the localization changes conditional in the
local.l10n.xml parameter. You can do that by using a parameter in the
document() function, and making the parameter value conditional.  Here is a
complete example:

<xsl:param name="local.gentext.source">
  <xsl:choose>
    <xsl:when test="/book/bookinfo/subtitle[.='Use Case  Report']">
      <xsl:value-of select="''"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:copy-of select="."/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:param>

<xsl:param name="local.l10n.xml" select="document($local.gentext.source)"/>

<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0";>
  <l:l10n language="pt_br">
    <l:context name="title-numbered">
      <l:template name="chapter"
                  text="Caso de Uso %n: &#8220;%t&#8221;" />
    </l:context>
    <l:context name="xref-number-and-title">
      <l:template name="chapter"
                  text="Caso de Uso %n: &#8220;%t&#8221;" />
    </l:context>
  </l:l10n>
</l:i18n>

<xsl:template match="chapter" mode="label.markup">
  <xsl:choose>
    <xsl:when test="/book/bookinfo/subtitle[.='Use Case  Report']">
      <xsl:value-of select="@id"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-imports/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

The first part has an xsl:choose statement inside parameter named
'local.gentext.source'. If your condition is true, it sets the value to an
empty string (that's two single quotes inside the double quotes).  If it is
false, it sets it to the current node represented by the dot.  In the
document() function, an empty string is taken to mean the current stylesheet
file, so it will read the l:i18n element in your customization.  If the
condition is false, it will read the document element, and won't find any
l:i18n element in your document (I hope).  This leaves the $local.l10n.xml
value empty, which is the default, so it will use the original gentext
templates for chapter.

The l:i18n element establishes new gentext templates for chapter title and
xref.

The last part generates the chapter number using the 'label.markup' mode.
It is conditional as well, so that if your condition is true it will return
the @id, and if it is false it will return the traditional number by using
apply-imports to use the original label.markup template for chapter.

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net


----- Original Message ----- 
From: "Paulo Eduardo Neves" <pauloneves@gmail.com>
To: "docbook list" <docbook-apps@lists.oasis-open.org>
Sent: Tuesday, May 10, 2005 1:46 PM
Subject: [docbook-apps] Changing chapter title to include chapter id


I'm using docbook to write use cases for a software application. I'm
trying to do some customizations, but I'm stucked.

The perfect customization would be in 3 steps:
   1) Change  "Chapter" to "Caso de Uso" (use case in Portuguese). Each
       use case  is written as a chapter.

   2) Add the chapter to the chapter title. Since each Use Case have an
       id, it'd be nice to use it as the chapter id. The references
would be a lot clearer, and
       the doc generation would break if there's any duplicate id.
       Example: <chapter id="uc330"><title>Do stuff</title>  would become
       Use Case uc330: "Do stuff"

   3) This one isn't really necessary, but since we're in it, here it goes.
       The rules above should
       just be applied when the document has the subtitle "Use Case
Report" (the
       xpath expression /book/bookinfo/subtitle[.='Use Case  Report'] is
true)

I'm stuck at 1). I did it following the instructions in
http://www.sagehill.net/docbookxsl/CustomXrefs.html#XrefGentext
I did:
<xsl:param name="local.l10n.xml" select="document('')"/>
<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0";>
  <l:l10n language="pt_br">
    <l:context name="title-numbered">
      <l:template name="chapter"
                  text="Caso de Uso &#8220;%t&#8221;" />
    </l:context>
  </l:l10n>
</l:i18n>


There are so many configuration options that I'm still trying to grok
all this template processing. If anybody can point me in the right
direction, it would be a great help. Thanks in advance.

Regards,
-- 
Paulo Eduardo Neves
Agenda do Samba & Choro
http://www.samba-choro.com.br

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