Link to home
Start Free TrialLog in
Avatar of APConnextion
APConnextion

asked on

Help with pagination in xsl file?

I was peeking at some other pagination posts, and couldn't quite figure out how to fit the xsl pagination into the code. How can I paginate the code in xsl, say, 6 records per page, with previous and next buttons or links for the user?

The top of my code currently looks like this:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:fx="#fx-functions" exclude-result-prefixes="msxsl fx">
    <xsl:output method="html" version="4.0" indent="yes" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
    <xsl:template match="//dataroot" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <html>
            <head>
                <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8"/>
                <title>scv-central</title>
                <style type="text/css">
                 </style>
           </head>
            <body link="#0000ff" vlink="#800080">
                <xsl:variable name="GlobalGroup" select="Qscv-central"/>
                <!-- Calculate expressions and running sums -->
                <xsl:value-of select="fx:CalculateExpressions_Global($GlobalGroup[1], $GlobalGroup)"/>
                <div style="BORDER-STYLE: none; WIDTH: 3.5in; BACKGROUND-COLOR: #ece9d8; VISIBILITY: visible; HEIGHT: 0in; POSITION: relative">
                </div>
                <xsl:for-each select="Qscv-central">
                    <xsl:sort select="Area" order="ascending" data-type="text"/>
                    <xsl:sort select="Rent" order="ascending" data-type="number"/>
                    <!-- Calculate expressions and running sums -->
                    <xsl:value-of select="fx:CalculateExpressions_Detail(., $GlobalGroup)"/>
                    <div style="BORDER-STYLE: none; WIDTH: 3.5in; BACKGROUND-COLOR: #ebebeb; VISIBILITY: visible; HEIGHT: 3.25in; POSITION: relative">
                        <span class="Style0" style="LEFT: 0.0833in; TOP: 0.0833in; WIDTH: 0.6666in; HEIGHT: 0.177in; POSITION: absolute">
                            <xsl:value-of select="Area"/>
                        </span>
                        <span class="Style1" style="LEFT: 1.8229in; TOP: 0.0729in; WIDTH: 1.6041in; HEIGHT: 0.1875in; OVERFLOW: hidden; POSITION: absolute">
                            <xsl:value-of select="Address"/>
                        </span>

It goes on from there. And the xml for one record looks like this (there are more fields in each record, but I just made it shorter for expediency purposes):

<Qscv-central>
        <Print>1</Print>
        <SMA>SCV</SMA>
        <New>0</New>
        <SS>0</SS>
        <Area>Central</Area>
        <Address>1701 Industrial Street</Address>
        <Rent>0</Rent>
</Qscv-central>

Thank you!
Avatar of Duane Lawrence
Duane Lawrence
Flag of United States of America image

I found a couple of examples that will help.

http://www.perfectxml.com/XSLFO.asp

http://forums.devshed.com/t54150/s.html

Duane
Avatar of APConnextion
APConnextion

ASKER

I peeked at those.  I ended up using this:

https://www.experts-exchange.com/questions/20537316/pagination-in-XSL.html?query=pagination+in+xml&clearTAFilter=true

But it's coming up with an error that says:
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.

/scv/central.asp, line 21

Can someone help me with this?  My xsl now looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet[
<!ENTITY newLine    "&#10;">
<!ENTITY headerCo   "    CENTRAL REPORT     Page: ">
]>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:fx="#fx-functions" exclude-result-prefixes="msxsl fx">
    <xsl:output method="html" version="4.0" indent="yes" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
    <xsl:param name= "numberperpage" select="3" />
    <xsl:template match="//dataroot" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <html>
            <head>
                <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8"/>
                <title>scv-central</title>
                <style type="text/css">
                </style>
            </head>
            <body link="#0000ff" vlink="#800080">
                <xsl:variable name="GlobalGroup" select="Qscv-central"/>
                <!-- Calculate expressions and running sums -->
                <xsl:value-of select="fx:CalculateExpressions_Global($GlobalGroup[1], $GlobalGroup)"/>
                <div style="BORDER-STYLE: none; WIDTH: 3.5in; BACKGROUND-COLOR: #ece9d8; VISIBILITY: visible; HEIGHT: 0in; POSITION: relative">
                </div>
                <xsl:for-each select="Qscv-central">
                    <xsl:sort select="Area" order="ascending" data-type="text"/>
                    <xsl:sort select="Rent" order="ascending" data-type="number"/>
                    <!-- Calculate expressions and running sums -->
                    <xsl:value-of select="fx:CalculateExpressions_Detail(., $GlobalGroup)"/>
                   
                    <xsl:if test="position() mod $numberperpage = 1"><xsl:text>&headerCo;</xsl:text><xsl:value-of select="((position() + $numberperpage)-1) div $numberperpage"/>          
                              <xsl:text>&newLine;</xsl:text>
                 </xsl:if>

The asp page looks like this:
<%
Set objData = CreateDOM
objData.async = false

if (false) then
      Set objDataXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
      objDataXMLHTTP.open "GET", "", false
      objDataXMLHTTP.setRequestHeader "Content-Type", "text/xml"
      objDataXMLHTTP.send
      objData.load(objDataXMLHTTP.responseBody)
else
      objData.load(Server.MapPath("Central.xml"))
end if

Set objStyle = CreateDOM
objStyle.async = false
objStyle.load(Server.MapPath("Central.xsl"))
Session.CodePage = 65001

Response.ContentType = "text/html"
Response.Write objData.transformNode(objStyle)

Function CreateDOM()
      On Error Resume Next
      Dim tmpDOM

      Set tmpDOM = Nothing
      Set tmpDOM = Server.CreateObject("MSXML2.DOMDocument.5.0")
      If tmpDOM Is Nothing Then
            Set tmpDOM = Server.CreateObject("MSXML2.DOMDocument.4.0")
      End If
      If tmpDOM Is Nothing Then
            Set tmpDOM = Server.CreateObject("MSXML.DOMDocument")
      End If
      
      Set CreateDOM = tmpDOM
End Function
%>

Does someone know what I'm missing? I know it has to be close . . .



And I still don't know about the next and previous links . . .
msxml4.dll error '80004005'

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q316297
CAUSE
The content model of a type definition in the XSD is non-deterministic (ambiguous). For additional information about deterministic content models, see the "More Information" section of this article.
RESOLUTION
Identify the type definition that contains the non-deterministic content model and make the changes required to make the content model deterministic (unambiguous).


In plain english, the definition of your xsl has a problem.  I will look for it on my end also, but I wanted to get this up so you can read it.

Duane
Thank you Duane. It seemed to stem from adding the DOCTYPE section at the top of the xsl document. Before I added that (and the corresponding bits a little further down the xsl), it came up without an error, but put the number 1, then three records, then the number 2, and three records, and so on. Not on seperate pages, tho. Just scrolling down. It divided them into three's and numbered them.

Do you know how we can fix this? Your help is much appreciated.
Actually, I don't think this code is doing what I want it to. How do I get a page break in there after the groups of records and have previous and next links for the pages? Help!
ASKER CERTIFIED SOLUTION
Avatar of Duane Lawrence
Duane Lawrence
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I will take a look at that. My apologies for taking your time. I've appreciated your help though. And I've been doing quite a bit of reading, on and offline. Hundreds of pages trying to figure out how to make this and numerous other things happen. Mainly dealing with XML, VB, and PHP.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial