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

client side paging using XML, XSLT, and script from w

Subject: client side paging using XML, XSLT, and script from www.bayes.co.uk?
From: "Subscriptions @ Team 7 Projects" <subscriptions@xxxxxxxxxxxxxxxxx>
Date: Thu, 4 Aug 2005 21:42:39 +0200
javascript paging
Hi All,

I am in need of some desperate help here. I am attempting to use the article
found on http://www.bayes.co.uk with respect to client side paging using XML
and XSLT. I have searched high and low on the web and have not managed to
find an answer/solution to my problem. Hoping someone can help.

Basically, I am using ASP.Net and SQL Server to return to me a randomised
result set. I then manually build up a XML document and use the stylesheet
example and javascript function from the bayes website to do the client side
paging. It filters nicely, i.e. displaying only 5 records, but when I click
the next 'button' and it executes the javascript it gives me an "object
error".

It seems to be at this point: "navigator.XSLDocument.xml" - undefined.

Remember my XML is created manually and dynamically.

I have found an article on the list that has the same problem, but there
does not seem to be a solution. Can someone please help. Below are code
extracts to help explain....

Thanx in advance

--------------------- ASP.Net C# code extract Start
------------------------------------------
System.IO.StringReader strReader = new System.IO.StringReader(xmlData);
xpathDoc = new XPathDocument(strReader); XslTransform transform = new
XslTransform(); transform.Load(Server.MapPath("results_page.xslt"));
transform.Transform(xpathDoc,null,Response.Output,new XmlUrlResolver());
--------------------- ASP.Net C# code extract End
------------------------------------------
-------------------------------- XML Start
---------------------------------------------------
<series>
	<page>
		<ad>
			<CompanyName>ABC (Pty) Ltd.</CompanyName>
			<ContactPerson>Mr ABC</ContactPerson>
			<Email>me@xxxxxxxx</Email>
		</ad>
		<ad>
			<CompanyName>Co. B</CompanyName>
			<ContactPerson>Trust Me</ContactPerson>
			<Email>test@xxxxxxxxx</Email>
		</ad>
	</page>
	<page>
		<ad>
			<CompanyName>ABC (Pty) Ltd.</CompanyName>
			<ContactPerson>Mr ABC</ContactPerson>
			<Email>me@xxxxxxxx</Email>
		</ad>
	</page>
</series>
--------------------------------- XML End
---------------------------------------------------

My XSLT is as follows:
------------------------------- XSLT Start
--------------------------------------------------

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="pagenumber" select="1" />

<xsl:template match="*|@*">
	<xsl:copy>
		<xsl:apply-templates select="@* | * | comment() |
processing-instruction() | text()" />
	</xsl:copy>
</xsl:template>

<xsl:template match="series">
<html>
	<head>
		<!-- <link rel="stylesheet" type="text/css"
href="slider.css" />  -->
		<!-- <script language="javascript" src="slider.js" />  -->
	</head>
	<body>
		<script language="javascript">
				function changePage(number){
						try{
							var s = new
ActiveXObject("MSXML2.FreeThreadedDOMDocument");
							var x =
document.XMLDocument;
							if (x == null){
								x =
navigator.XMLDocument;

s.loadXML(navigator.XSLDocument.xml);


							}else{

s.loadXML(document.XSLDocument.xml);


							}
							var tem = new
ActiveXObject("MSXML2.XSLTemplate");
							tem.stylesheet = s;
							var proc =
tem.createProcessor();

proc.addParameter("pagenumber", number);
							proc.input = x;
							proc.transform();
							var str =
proc.output;
							var newDoc =
document.open("text/html", "replace");
							newDoc.write(str);

navigator.XMLDocument = x;

navigator.XSLDocument = s;
							newDoc.close();
						}catch(exception){
							alert(exception);
						}
					}
			</script>
		<xsl:apply-templates select="page[$pagenumber]" />
				<xsl:call-template name="footerPages">
					<xsl:with-param name="element"
select="'page'" />
					<xsl:with-param name="pagenumber"
select="$pagenumber" />
				</xsl:call-template>
	</body>
</html>
</xsl:template>

<xsl:template match="ad">
	<table width="600" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="112">Company Name:</td>
		<td colspan="3"><xsl:value-of select="CompanyName"/></td>
		<td><font size="1" face="MS Sans Serif, MS Serif">Contact
Person:</font></td>
		<td><font size="1" face="MS Sans Serif, MS
Serif"><xsl:value-of select="CPerson"/></font></td>
		<td><font size="1" face="MS Sans Serif, MS Serif">E-Mail
Address:</font></td>
		<td><font size="1" face="MS Sans Serif, MS
Serif"><xsl:value-of select="PriEMail"/></font></td>
	</tr>

	</table>
</xsl:template>

<xsl:template name="footerPages">
	<xsl:param name="element" />
	<xsl:param name="pagenumber" />
	<xsl:variable name="total" select="count(*[name() = $element])" />
	<center>
		<xsl:if test="$pagenumber &gt; 1">
			<a href="JavaScript:changePage({$pagenumber
-1});">Prev</a>
		</xsl:if>
		<xsl:for-each select="*[name() = $element]">
			<xsl:choose>
				<xsl:when
test="not(count(preceding-sibling::*)+1 = $pagenumber)">
					<a
href="JavaScript:changePage({count(preceding-sibling::*)+1});">
						<xsl:value-of
select="count(preceding-sibling::*)+1" />
					</a>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of
select="count(preceding-sibling::*)+1" />
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
		<xsl:if test="$pagenumber &lt; $total">
			<a href="JavaScript:changePage({$pagenumber
+1});">Next</a>
		</xsl:if>
	</center>
</xsl:template>
</xsl:stylesheet>

----------------------------------- XSLT END
----------------------------------------

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.