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 July 28th, 2005, 09:56 AM
Registered User
 
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Solution!

Cracked it...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:param name="user_name">****</xsl:param>
    <xsl:param name="faculty">ITS</xsl:param>
    <xsl:param name="action_url">action not set</xsl:param>
    <xsl:param name="photo_server">not found</xsl:param>
    <xsl:param name="page_number">0</xsl:param>
    <xsl:param name="group_name">Not been set yet...</xsl:param>
    <xsl:param name="startingPhoto">21</xsl:param>
    <xsl:param name="howMany">5</xsl:param>

    <xsl:template match="/">
        <head>
            <link type="text/css" rel="stylesheet" href="css/myuwe.css"/>
        </head>
        <table width="640">
            <tr>
                <td colspan="2">
                    <h2>View Photos</h2>
                </td>
            </tr>
            <tr>
                <td width="420">Name: <xsl:value-of select="$user_name"/><br/>Your Faculty: <xsl:value-of
                        select="$faculty"/></td>
                <td valign="top" align="right">
                    <xsl:apply-templates select="/PhotosData/groups"/>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <xsl:apply-templates select="/PhotosData/photos"/>
                </td>
            </tr>
        </table>
    </xsl:template>

    <xsl:template match="groups">
        <form method="post" action="{$action_url}">
            <select name="selected-group">
                <xsl:apply-templates select="group"/>
            </select>
            <input type="submit" value="select group"/>
        </form>
    </xsl:template>
    <xsl:template match="group">
        <xsl:variable name="groupName">
            <xsl:value-of select="."/>
        </xsl:variable>
        <option value="{$groupName}">
            <xsl:value-of select="$groupName"/>
        </option>
    </xsl:template>

    <xsl:template match="photos">
        <xsl:variable name="count" select="count(record)"/>
        <xsl:variable name="previous" select="number($startingPhoto - $howMany)"/>
        <xsl:variable name="next" select="number($startingPhoto + $howMany)"/>
        <table cellpadding="5" border="4" width="640" align="left">

            <tr>
                <td>
                    <h3>Photos for <em>
                            <xsl:value-of select="$group_name"/>
                        </em></h3>
                </td>
            </tr>
            <tr>
                <td>
                    viewing page number <xsl:value-of select="$page_number"/>
                </td>
            </tr>
            <tr>
                <td>
                    <xsl:call-template name="displayPhotos">
                        <xsl:with-param name="currentNodes" select="//record[position() &gt;= $startingPhoto and position() &lt;($startingPhoto +
                            $howMany)]"></xsl:with-param>
                    </xsl:call-template>
                </td>
            </tr>
            <tr>
                <td>

                        <xsl:choose>
                            <xsl:when test="$startingPhoto = 1">
                                    <xsl:text>None</xsl:text>
                            </xsl:when>
                            <xsl:otherwise>
                                <a href="{$action_url}?startingPhoto={$previous}">pre vious<xsl:value-of select="$howMany"/></a>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:choose>
                            <xsl:when test="($startingPhoto + $howMany) &gt;= $count">
                                <xsl:text>None</xsl:text>
                            </xsl:when>
                            <xsl:otherwise>
                                <a href="{$action_url}?startingPhoto={$next}">next<xs l:value-of select="$howMany"/></a>
                            </xsl:otherwise>
                        </xsl:choose>

                </td>
            </tr>
        </table>
    </xsl:template>
    <xsl:template name="displayPhotos">
        <xsl:param name="currentNodes"/>
        <xsl:for-each select="$currentNodes">
                    Name: <xsl:value-of select="name"/>
                <xsl:if test="position() mod 5 =0">
                    <br/>
                </xsl:if>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>


:)

 
Old July 30th, 2005, 08:05 AM
Authorized User
 
Join Date: Jul 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Aaron,

Could you please post the xml used with this xlst?

Cheers






Similar Threads
Thread Thread Starter Forum Replies Last Post
need solution nandhamca22 CSS Cascading Style Sheets 1 February 7th, 2006 10:16 AM
please tell me the solution prashar SQL Server 2000 0 December 9th, 2005 12:11 PM
what's the best solution for: eresina ASP.NET 1.0 and 1.1 Basics 2 November 16th, 2004 10:46 AM
Which solution should go eureka BOOK: ASP.NET Website Programming Problem-Design-Solution 1 September 5th, 2004 12:09 AM
Solution for solution eureka BOOK: ASP.NET Website Programming Problem-Design-Solution 4 August 15th, 2004 11:07 AM





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