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] XSLT to insert Indexterms


nix4 wrote:

> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>   <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
>       <xsl:template match="sect1/title">
>        <xsl:copy-of select="."/>
>        <indexterm>
>           <primary>
>              <xsl:value-of select="."/>
>           </primary>
>        </indexterm>
>        <xsl:apply-templates select="."/>
>     </xsl:template>
>     <xsl:template match="/">
>     <xsl:copy-of select="."/>
>  </xsl:template>
> </xsl:stylesheet>

> This stylesheet re-creates the input XML fine, but it ignores the
> first template and never inserts the indexterm element.

  Indeed, you asked it to copy the whole document, and never apply
templates...  Here is a solution (please look for Modified Identity
Transform pattern):

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

       <xsl:output indent="yes"/>

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

       <!-- Add an index term after the title -->
       <xsl:template match="sect1/title">
	  <xsl:copy-of select="."/>
	  <indexterm>
	     <primary>
		<xsl:value-of select="."/>
	     </primary>
	  </indexterm>
	  <xsl:apply-templates select="."/>
       </xsl:template>

    </xsl:stylesheet>

  Regards,

--drkm




















      _____________________________________________________________________________ 
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr



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