Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 15th, 2014, 11:19 AM
Authorized User
Points: 151, Level: 3
Points: 151, Level: 3 Points: 151, Level: 3 Points: 151, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:06 PM.


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