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] Select user-element inside <indexterm> in autoindex


On Tue, Nov 11, 2003 at 10:30:03AM -0500, Mykone Saunders wrote:
> Anybody know how to get specific tag to output in the AutoIndex?
> 
> Example, I have the following user-defined element:
> 
> <indexterm zone="intro">
> 	<primary>
> 		<translation>
> 			<english>Introduction</english>
> 			<french>Introductiones</english>
> 		</translation>
> 	</primary>
> </indexterm>
> 
> What XSL customization would I had to print only the translation/french
> element as my index entry?
> 
> Your assistance would be greatly appreciated. Thanks in advance.

Customizing the XSL indexterm templates is a serious challenge.
Those are among the most complex templates in the stylesheets.
But you can avoid that problem entirely.

Your file is a classic case of profiling, except you
are using your own tags.  Here is a stylesheet that
does an identity transform, except that it maps your
custom language tags to standard phrase elements with
a lang attribute.  Then you can use the profiling
stylesheet with the profile.lang stylesheet parameter
to process the result. 

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

<xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates/>
   </xsl:copy>
</xsl:template>

<!-- convert language tags to phrase with lang attribute --> 

<xsl:template match="translations">
      <xsl:apply-templates/>
</xsl:template>

<xsl:template match="english">
     <phrase lang="en">
	 <xsl:apply-templates/>
     </phrase>
</xsl:template>

<xsl:template match="spanish">
     <phrase lang="es">
	 <xsl:apply-templates/>
     </phrase>
</xsl:template>

<xsl:template match="french">
     <phrase lang="fr">
	 <xsl:apply-templates/>
     </phrase>
</xsl:template>

</xsl:stylesheet>

Then the transformation is done in four steps
(maybe in a Makefile):

	xsltproc \
	-output mykone.tmp.xml \
	the_above_stylesheet.xsl \
	mykone.xml

	xsltproc \
	-output mykone.profiled.xml \
	--stringparam profile.lang "es" \
	../docbook-xsl-1.62.4/profiling/profile.xsl \
	mykone.tmp.xml
	
	xsltproc \
	-output mykone.fo \
	--stringparam fop.extensions 1 \
	../docbook-xsl-1.62.4/fo/docbook.xsl \
	mykone.profiled.xml

	fop.sh mykone.fo mykone.pdf

It is a different approach, but a lot easier to
implement than customizing the index templates.
And it happens to work for all other elements in
your documents as well.
-- 

Bob Stayton                                 400 Encinal Street
Publications Architect                      Santa Cruz, CA  95060
Technical Publications                      voice: (831) 427-7796
The SCO Group                               fax:   (831) 429-1887
                                            email: bobs@sco.com


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