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
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]