Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: prev/next ability within XSLT [Thread Next] Re: prev/next ability within XSLTTo: NULL Date: 10/6/2005 9:53:00 AM Thanks Martin,
given that I have to use some script, I have come up with a solution.
Just in case anyone cares, here it is...
(note: I have left out some of the formatting to reduce the size of the
post so I cannot say that this will work as-is)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:dt="urn:schemas-microsoft-com:datatypes" version="1.0">
<xsl:template match='/'>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="root" >
<xsl:param name="pagenumber" select="1" />
<table>
<xsl:call-template name="pager">
<xsl:with-param name="element" select="'Property'" />
<xsl:with-param name="pagenumber" select="$pagenumber" />
</xsl:call-template>
<xsl:apply-templates select="Property" />
</table>
</xsl:template>
<xsl:template match="Property">
<tr>
<td>Property Code:</td>
<td><input type="text">
<xsl:attribute name="value">
<xsl:value-of select="@vCode"/>
</xsl:attribute>
</input>
</td>
<td>Property Name:</td>
<td><input type="text">
<xsl:attribute name="value">
<xsl:value-of select="@vTIN"/>
</xsl:attribute>
</input>
</td>
</tr>
</xsl:template>
<xsl:template name="pager">
<xsl:param name="element" />
<xsl:param name="pagenumber" />
<xsl:variable name="total" select="count(*[name() = $element])" />
<tr><td>
<xsl:text>Property: </xsl:text><xsl:number value="$pagenumber"
/><xsl:text>
of </xsl:text> <xsl:value-of select="$total" />
</td>
<td>
<xsl:choose>
<xsl:when test="$pagenumber = 1">
<xsl:text>Prev | </xsl:text>
<a href="JavaScript:changePage({$pagenumber +1});">Next</a>
</xsl:when>
<xsl:when test="$pagenumber = $total">
<a href="JavaScript:changePage({$pagenumber -1});">Prev</a>
<xsl:text> | Next</xsl:text>
</xsl:when>
<xsl:otherwise>
<a href="JavaScript:changePage({$pagenumber -1});">Prev</a>
<xsl:text> | </xsl:text>
<a href="JavaScript:changePage({$pagenumber +1});">Next</a>
</xsl:otherwise>
</xsl:choose>
</td></tr>
</xsl:template>
</xsl:stylesheet>
and the javascript:
function changePage(number){
//note that thexml (XML Doc) and calxsl (XSL) were already defined in
my ASP page
var nodes = calxsl.selectNodes("xsl:stylesheet/xsl:template");
for ( i=0; i < nodes.length; i++ )
{
currNode = nodes[i];
if( currNode.getAttribute("match") == 'root')
{
//set the default param value to the new number
thenode = currNode.selectSingleNode("xsl:param");
thenode.setAttribute("select",number);
break;
}
}
//xsldest is a DIV element object in my ASP page
xsldest.innerHTML = thexml.transformNode(calxsl.documentElement);
}
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
