[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Generating table cells and rows

Subject: Re: Generating table cells and rows
From: Aaron Johnson <artpunx@xxxxxxxxx>
Date: Mon, 1 Aug 2005 15:05:25 +0100
atg template
Hello David...

 I had a go at implimenting your solution but could'nt "bolt it in". I
had worked out my style sheet to grab a set of nodes and test the
amount of images so as to display links that would determine the next
or previous set of images. I understand the logic behind your solution
regarding the following siblings etc.

Here is my style sheet if you'd like a glance:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atg="http://atg.uwe.ac.uk/portal/photosPortlet" version="1.0">
	<xsl:param name="user_name">****</xsl:param>
	<xsl:param name="faculty">****</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">1</xsl:param>
	<xsl:param name="howMany">10</xsl:param>

	<xsl:template match="/">
		<head>
			<link type="text/css" rel="stylesheet" href="css/myuwe.css"/>
		</head>
		<table>
			<tr>
				<td colspan="2"><h1>Photos Portlet</h1></td>
			</tr>
			<tr>
				<td>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="/atg:PhotosData/groups"/></td>
			</tr>
			<tr>
				<td colspan="2"><xsl:call-template name="photos">
					<xsl:with-param name="recordsInGroup"
select="//atg:record[../@groupName=$group_name]" />
				</xsl:call-template></td>
			</tr>
		</table>
	</xsl:template>

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

	</xsl:template>

	<xsl:template match="atg:group">
		<xsl:variable name="groupName">
			<xsl:value-of select="."/>
		</xsl:variable>
		<option value="{$groupName}">
			<xsl:value-of select="$groupName"/>
		</option>
	</xsl:template>

	<xsl:template name="photos">
	<xsl:param name="recordsInGroup"/>
	<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="1" align="left">
			<!-- group_name should be set only if photos are available -->
			<tr>
				<td>
					<h3>Photos for <em><xsl:value-of select="$group_name"/></em></h3>
				</td>
			</tr>

			<!-- page number code removed and stored at the bottom of this stylesheet
-->

			<tr>
				<td>
					<xsl:call-template name="displayPhotos">
					<xsl:with-param name="currentNodes"
select="$recordsInGroup[position() &gt;= $startingPhoto and position()
&lt;($startingPhoto +  $howMany)]"/>
					</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}">  Previous
<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
<xsl: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">
			<img src="{$photo_server}/?studentId={id}"/><br /> Name:
<xsl:value-of select="atg:name"/>
		<xsl:if test="position() mod 5 =0"><br/></xsl:if>
		</xsl:for-each>
	</xsl:template>

</xsl:stylesheet>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.