|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
XSL Pagination using MSXML DOM
I need to implement pagination on the results of a XSLT transformation, because the result sometimes is way too big for the browser to display.
I am using the following xslt (server Side), in wich I implemented a snippet of code wich I found at http://aspn.activestate.com/ASPN/Co...T/Recipe/117251 wich was written by Brandon Croft The part in italics is a just part of the working code, wich does the most of the transformation, so don't pay attention to it. (cause is already working) If someone could help me with this pagination issue I will really appreciate it. Thanks in advance. Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- tabglobal__ShowRecords.xsl -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="sortKey" select="'consec'"/>
<xsl:param name="sortOrder" select="'ascending'"/>
<xsl:param name="Page" select="0"/>
<xsl:param name="PageSize" select="5"/>
<xsl:template match="/xml/xml">
<xsl:apply-templates select="rows"/>
</xsl:template>
<xsl:template match="rows">
<xsl:apply-templates select="row">
<xsl:sort select="*[name(.)=$sortKey]|@*[name(.)=$sortKey]" order="{$sortOrder}"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="row">
<xsl:if test="position() >= ($Page * $PageSize) + 1">
<!-- Check to see if we have returned the right number of results yet. -->
<xsl:if test="position() <= $PageSize + ($PageSize * $Page)">
<!-- Do Some Work -->
<xsl:choose>
<xsl:when test="position() mod 2 > 0">
</xsl:otherwise>
</xsl:choose>
<!-- ENDS Do Some Work -->
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
The part of the code wich is between the <!-- Do Some Work --> is what actually formats the XML file to HTML, when I don't use that 2 conditions everything works fine, but when I try to apply the position conditions the server returns the following error, wich gets solved when I take this two conditions (in bold) Code:
msxml4.dll error '80004005' The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document. /c4bcsrel/utilities/utilities.asp, line 386 I am using ASP on IIS 5 with the MSXML2.FreeThreadedDOMDocument.4.0 and the MSXML2.XSLTemplate.4.0 implemented on a function wich I found at http://www.aspfree.com/authors/robe...ault.asp?aid=99 written by Robert Chartier for applying the xsl file to the xml. |
|
#2
|
|||
|
|||
|
When I run the XSL transformation using XML Spy 5 with the MSXML XSL engine version 4 it says that
"The character < cannot be used in an attribute value" it reffers to this part <xsl:if test="position() <= $PageSize + ($PageSize * $Page)"> I don't know how to use the < in a comparation when is not allowed to be used, maybe there is a work around for this situation. Any help will be appreciated. |
|
#3
|
|||
|
|||
|
The error is that you should use the > and & lt notation instead of the greater than and lower than sign when using it in numerical comparations, so the code should look like here bellow
<xsl:if test="position() <= $PageSize + ($PageSize * $Page)"> have funn. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XSL Pagination using MSXML DOM |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|