XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Yama KamyarSubject: Paging with XSL and passing URL parameter (using javascript)
Author: Yama Kamyar
Date: 22 Sep 2008 01:57 PM
Originally Posted: 19 Sep 2008 01:27 PM
Hi,

I have a very large XML file in CruiseControl.NET 1.4 which I want to display its data to the browser.

In my XSL I have created the following:

<xsl:param name="pageNumber" select="0" />

When the user clicks on a "Next" link the page is refreshed with the addition of http://server/page.aspx?pageNumber=2

I have tried using msxml:script but it did not work because it complained about a javascript object: window.location.href. The error was it could not locate 'window' object or something like that.

ALL I want is when the page refreshes I get:

the value of pageNumber
http://server/page.aspx?pageNumber=2

populate this:
<xsl:param name="pageNumber" select="2" />

Very pretty straight forward but could not figure out how... I searched everywhere on the web and could not find anything.

Is there a solution you know of?

Thanks,
Yama

Posttop
Yama KamyarSubject: Paging with XSL and passing URL parameter (using javascript)
Author: Yama Kamyar
Date: 22 Sep 2008 01:59 PM
Originally Posted: 19 Sep 2008 05:40 PM
for those of you who think this wasn't possibly... Here is the solution:

<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:csharp="http://csharp"
exclude-result-prefixes="xsl msxml csharp">

<msxml:script implements-prefix="csharp" language="C#">
<msxml:using namespace="System.Collections"/>
<msxml:assembly name="System.Web"/>
<msxml:using namespace="System.Web"/>
<![CDATA[
public int GetPageNumber() {
int page = 0;
if(HttpContext.Current.Request.QueryString["pageNumber"] != null)
{
if(HttpContext.Current.Request.QueryString["pageNumber"].Length > 0)
{
page = Convert.ToInt32(HttpContext.Current.Request.QueryString["pageNumber"]);
}
}
return page;
}
]]>
</msxml:script>

<xsl:output method="html"/>
<xsl:template match="/">
<script type="text/javascript">
function foo()
{ return "your javascript here"; }
</script>
<style type="text/css">
body {
font:normal 88% verdana,arial,helvetica;
color:#000000;
}
table tr td, tr th {
font-size: 88%;
}
</stlye>
</xsl:template>
<xsl:template match="files">
<xsl:param name="recordsPerPage" select="10" />
<xsl:param name="pageNumber" select="number(csharp:GetPageNumber())" />
<xsl:param name="recordCount" select="count(//file)" />

<xsl:for-each select="//file">

<xsl:if test="position() &gt; $recordsPerPage * number($pageNumber) and
position() &lt;= number($recordsPerPage * number($pageNumber) +
$recordsPerPage)">

<!-- Display 50Mb XML -->
</xsl:if>
</xsl:for-each>


<span style="Z-INDEX: 101; LEFT: 261px; WIDTH: 501px;">
<xsl:if test="$pageNumber &gt; 0">
<xsl:element name="a">
<xsl:attribute name="href">?pagenumber=<xsl:value-of select="number($pageNumber)-1" />
</xsl:attribute>
&lt;&lt; Previous Page
</xsl:element>
&#160; &#160; &#160; &#160;
</xsl:if>
<xsl:if test="($recordCount - ((1+number($pageNumber)) * $recordsPerPage))&gt; 0">
<xsl:element name="a">
<xsl:attribute name="href">?pagenumber=<xsl:value-of select="number($pageNumber)+1" />
</xsl:attribute>
Next page &gt;&gt;
</xsl:element>
</xsl:if>
</span>

</xsl:template>


Hope this helps many others. Please let me know if anyone has questions.

Yama Kamyar

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.