Sign Up
Search
Options
search
Chat
Help
News
Log in
Not Logged in
Home
»
Boards
»
Stylus Studio Developer Network
»
XSLT Help and Discussion
»
Paging with XSL and passing URL parameter (using javascript)
Topic
Topic Page
1
2
3
4
5
6
7
8
9
Prev Topic
Next Topic
next
Subject:
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
top
Subject:
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() > $recordsPerPage * number($pageNumber) and
position() <= 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 > 0">
<xsl:element name="a">
<xsl:attribute name="href">?pagenumber=<xsl:value-of select="number($pageNumber)-1" />
</xsl:attribute>
<< Previous Page
</xsl:element>
       
</xsl:if>
<xsl:if test="($recordCount - ((1+number($pageNumber)) * $recordsPerPage))> 0">
<xsl:element name="a">
<xsl:attribute name="href">?pagenumber=<xsl:value-of select="number($pageNumber)+1" />
</xsl:attribute>
Next page >>
</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
Prev Topic
Next Topic
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 to Conference:
Select Conference
Stylus Studio Feature Requests
Stylus Studio Technical Forum
Website Feedback
XSLT Help and Discussion
XQuery Help and Discussion
Stylus Studio FAQs
Stylus Studio Code Samples & Utilities
Stylus Studio Announcements
go
Log In Options
Username:
Password:
Site Map
|
Privacy Policy
|
Terms of Use
|
Trademarks
Stylus Scoop XML Newsletter:
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.