Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 15th, 2014, 11:19 AM
Authorized User
 
Join Date: Apr 2013
Posts: 31
Thanks: 3
Thanked 0 Times in 0 Posts
Angry get first following page value

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 8 Ajax.ActionLink, at page 197. PartialView displayed as its own page. JimiFriis BOOK: Professional ASP.NET MVC 4 1 March 25th, 2015 04:18 AM
PDF giving first page as blank if page count > 1 using xsl:fo srmxslca XSLT 14 May 5th, 2011 05:01 AM
can’t open the page because the server where this page is located isn’t responding m_alsobaai Forum and Wrox.com Feedback 3 July 15th, 2010 06:13 AM
How to print a web page without title, URL, page #, date and time Mattt C# 2 July 17th, 2009 03:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.