Hi,
I've the below XML file.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<toc-item>
<toc-title>A</toc-title>
<page>11/4/10A</page>
<page>cclxxi</page>
</toc-item>
<toc-item>
<toc-title>B</toc-title>
<page>11/5/1A</page>
</toc-item>
<toc-item>
<toc-title>C</toc-title>
<page>11/4</page>
<page>cclxxii</page>
</toc-item>
<toc-item>
<toc-title>B</toc-title>
<page>11/5/1A</page>
</toc-item>
<toc-item>
<toc-title>C</toc-title>
<page>11/4</page>
<page>cclxxiiv</page>
</toc-item>
</root>
and below XSLT.
HTML Code:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="html" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<xsl:apply-templates></xsl:apply-templates>
</xsl:template>
<xsl:template match="root">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="toc-item">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="toc-title">
<td class="toc-title">
<xsl:apply-templates/>
</td>
</xsl:template>
<xsl:template match="content-style">
<xsl:variable name="fontStyle">
<xsl:value-of select="concat('font-style-',@font-style)"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="./@font-style">
<span class="{$fontStyle}">
<xsl:apply-templates/>
</span>
</xsl:when>
<xsl:otherwise>
<span class="{concat('format-',./@format)}">
<xsl:apply-templates/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="page">
<xsl:choose>
<xsl:when test="not(preceding-sibling::page[1])">
<td class="toc-page" valign="bottom">
<xsl:value-of select="."/>
</td>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="first"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="page" mode="first">
<xsl:variable name="pgn">
<xsl:value-of select="./following::page/following-sibling::page[1]"/>
</xsl:variable>
<xsl:processing-instruction name="pb">
<xsl:text>label='</xsl:text>
<xsl:value-of select="$pgn"/>
<xsl:text>'</xsl:text>
<xsl:text>?</xsl:text>
</xsl:processing-instruction>
<a name="{concat('pg_',$pgn)}"/>
</xsl:template>
<xsl:template match="page" mode="two">
<xsl:processing-instruction name="pb">
<xsl:text>label='</xsl:text>
<xsl:value-of select="."/>
<xsl:text>'</xsl:text>
<xsl:text>?</xsl:text>
</xsl:processing-instruction>
<a name="{concat('pg_',.)}"/>
</xsl:template>
</xsl:transform>
here i'm trying to get the next page which has a preceding page, but here when i'm doing i get all the next pages.
Here is a working demo.
http://xsltransform.net/jyH9rM4
please let me know how can i fix this.
Thanks