Hi,
The problem is here:
<xsl:template match="div[(_at_)type='ss1']/head" mode="toc">
<xsl:apply-templates select="*[not(self::anchor or
self::pb)]|text()"/>
</xsl:template>
You match the head in mode toc and then apply the processing further in
the default mode excluding the anchor and pb that are children of the
matched head element. In your input you have anchor and pb inside title,
not as children of head.
One solution will be to put all the processing that you want for the
table of contents in the toc mode. All you need will be to remove the
above template and just add
<xsl:template match="anchor|pb" mode="toc"/>
<xsl:template match="sCap|bold|ital" mode="toc">
<span class="{name()}">
<xsl:apply-templates mode="toc"/>
</span>
</xsl:template>
The rest will be done by the built-in template rules that will supply
for you the equivalent of:
<xsl:template match="header|title" mode="toc">
<xsl:apply-templates mode="toc"/>
</xsl:template>
Best Regards,
George
--
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
J. S. Rawat wrote:
Yes I can understand!!!
INPUT
<docGroup>
<doc id="FFCP0002-DOC0001">
<head>...</head>
<docBody>
<div type="ss1">
<head>O<sCap>FFICERS</sCap> of the R<sCap>EGIMENT</sCap> of
I<sCap>NFANTRY</sCap><anchor id="a"/><pb n="b-4"/></head>
... </div>
<div type="ss1">
<head>
<title>(1) Extract of a <anchor id="b"/><pb n="b-5"/>Letter from
Governor <person>William Blount</person> to the Secretary of State</title>
</head> ... </div>
</docBody>
</doc>
</docGroup>
XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xd="http://www.pnp-software.com/XSLTdoc"
exclude-result-prefixes="xd"
version="1.0">
<xsl:output method="xml" indent="no"/>
<xsl:template match="doc">
<ul>
<xsl:for-each select="//docGroup//div[(_at_)type='ss1']">
<li><a><xsl:attribute name="href">#sec<xsl:number format="1"
count="//docGroup//div[(_at_)type='ss1']" level="any"
from="docGroup"/></xsl:attribute><xsl:apply-templates select="head"
mode="toc"/> </a> </li>
</xsl:for-each>
</ul>
<div id="content">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="div/head">
<xsl:choose>
<xsl:when test="../@type='ss1'">
<h2>
<xsl:apply-templates/>
</h2>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="div[(_at_)type='ss1']/head" mode="toc">
<xsl:apply-templates select="*[not(self::anchor or
self::pb)]|text()"/>
</xsl:template>
<xsl:template match="sCap|bold|ital">
<span class="{name()}">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="anchor">
<a name="{(_at_)id}">
<xsl:apply-templates/>
</a>
</xsl:template>
<xsl:template match="pb">
<a name="{(_at_)n}">
<xsl:apply-templates/>
</a>
</xsl:template>
</xsl:stylesheet>
REQUIRED RESULT
<?xml version="1.0" encoding="utf-8"?>
<ul xmlns="http://www.w3.org/1999/xhtml">
<li><a href="#sec1">O<span class="sCap">FFICERS</span> of the R<span
class="sCap">EGIMENT</span> of I<span class="sCap">NFANTRY</span></a></li>
<li><a href="#sec2">
(1) Extract of a Letter from Governor William Blount to the Secretary of
State
</a></li></ul>
<div xmlns="http://www.w3.org/1999/xhtml" id="content">
...
<h2>O<span class="sCap">FFICERS</span> of the R<span
class="sCap">EGIMENT</span> of I<span class="sCap">NFANTRY</span><a
name="a"/><a name="b-4"/></h2>
...
<h2>(1) Extract of a <a name="b"/><a name="b-5"/>Letter from Governor
William Blount to the Secretary of State
</h2> ...
</div>
At 01:55 PM 9/19/2008, David Carlisle wrote:
It's really a lot better if you post _complete_ but small stylesheets,
then people can run the stylesheet and comment on the result. If you
only post f ragments, then people can't run them, and often the problem
turns out to be in the part of the code not posted.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--