Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: prev/next ability within XSLT

From: "rich" <rwaldis@----------.--->
To: 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);
}



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent