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


Wow! Great customizations. It took a lot more magic than I thought.
Thanks a lot, Bob.

On 5/10/05, Bob Stayton <bobs@sagehill.net> wrote:
> ..so I presume you mean you need 2 and 3.

Yes, excuse my poor English. 

> 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".   

This xsl:apply-imports trick is nice, I hadn't met this element
before. It'll be useful.

A nice collateral effect of using the chapter @id for numbering is
that the use case with id "P100" the figures are indexed as "P100.1",
"P100.2"...

How would I have discovered -- by myself -- the '<xsl:template
match="chapter" mode="label.markup">'? Do you follow any strategy to
discover it, or I must be a xslt guru to know it? :-)

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

This i10n stuff is still like magic for me. I'll have to study it a little. 

I liked the technique to customise the document based in its content.
It allows me to enforce a style for each kind of document, and the
writer doesn't need to configure anything.

I'm posting below my final customization. I did two little
modifications: 1) used a normalize-space function in the xpath that
discover the kind of document, and 2) created a variable that
specifies the kind of document. It's better to have the definition in
just one place.

Two strings are in Portuguese:
"Relatório de Casos de Uso" -> Use Case Report
"Caso de Uso" -> Use Case

<!--use case customizations -->

<xsl:variable  name="document.class.usecasereport" 
               select="/book/bookinfo/subtitle[normalize-space(.)= 
                    'Relatório de Casos de Uso']"/>

<xsl:param name="local.gentext.source">
  <xsl:choose>
   <xsl:when test="$document.class.usecasereport">
     <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="$document.class.usecasereport">
     <xsl:value-of select="@id"/>
   </xsl:when>
   <xsl:otherwise>
     <xsl:apply-imports/>
   </xsl:otherwise>
  </xsl:choose>
</xsl:template>

Thanks again for the help.
-- 
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


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