?
Solved

send page number to xsl with asp

Posted on 2009-02-12
11
Medium Priority
?
395 Views
Last Modified: 2013-11-18
hi i am using below code in pageAAA.asp to do xml to html:                

                Dim objXML
      Dim objXSL
      Dim strHTML
      
      'Load the XML File
      Set objXML = Server.CreateObject("MSXML2.DOMDocument")
      objXML.async = False
      objXML.load(Server.MapPath("juxml.xml"))
      
      'Load the XSL File
      Set objXSL = Server.CreateObject("MSXML2.DOMDocument")
      objXSL.async = False
      objXSL.load(Server.MapPath("cusheet.xsl"))
      
      ' Transform the XML file using the XSL stylesheet
      strHTML = objXML.transformNode(objXSL)
      
      Set objXML = Nothing
      Set objXSL = Nothing
      
      ' Spit out the resulting HTML... the data comes from the
      ' .xml file, but the formatting of the results depends
      ' completely upon the .xsl file.
      Response.Write strHTML

it is working fine, but i am have a problem with passing the paging value to my stylesheet

the link i us to send the paging values looks like the following which is the same pageAAA.asp

http://www.testdev/mbstlast.asp?page=1&pagesize=1

below the stylesheet i am using

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="3.2" encoding="ISO-8859-1"/>
<xsl:param name="Page" select="0" />
<xsl:param name="PageSize" select="1" />
 
<xsl:template name="results" match="/">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Home</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link href="images/ement.css" rel="stylesheet" type="text/css" />
<link href="images/print.css" rel="stylesheet" type="text/css" media="print" />
</head>
<body>

<xsl:variable name="mycount" select="count(statement/page)"/>
<xsl:variable name="selectedRowCount" select="round($mycount div $PageSize)"/>
      <xsl:for-each select="statement/page">
       <!-- Pagination logic -->
       <xsl:if test="position() &gt;= ($Page * $PageSize) + 1">
        <xsl:if test="position() &lt;= $PageSize + ($PageSize * $Page)">

  <table width="670" height="700" cellpadding="0" cellspacing="0" class="borderthin" align="center">
    <tr>
        <td class="tblbgrnd-grey">
            <table width="92%"  border="0" align="center" cellpadding="0" cellspacing="0">
              <tr valign="bottom">
                   <td height="24"></td>
                <td></td>
          </tr>
          <tr valign="bottom">
                <td width="66%"><img src="images/cu_logo.gif" width="273" height="72" alt="Ma N.V." /></td>
                <td width="33%"><span class="address">Plrea 2-4<br />P.O. Box 305<br />Culles</span></td>
          </tr>
            </table>
            <br />
            <table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                  <td class="tblbgrnd"><img src="images/spacer.gif" width="10" height="1" alt="" /></td>
                  <td width="50%" class="tblbgrnd"></td>
                  <td><img src="images/spacer.gif" width="30" height="15" alt="" /></td>
                  <td class="tblbgrnd"><img src="images/spacer.gif" width="10" height="1" alt="" /></td>
                  <td width="50%" class="tblbgrnd"></td>
              </tr>
              <tr>
                  <td width="10" class="tblbgrnd"></td>
                  <td height="18" class="tblbgrnd" nowrap="nowrap"><span class="courier"><xsl:value-of select="stdata/header/addressline1"/></span></td>
                  <td height="18"></td>
                  <td class="tblbgrnd"></td>
                  <td height="18" class="tblbgrnd"><span class="stHeading"><xsl:value-of select="stdata/header/text1"/></span></td>
              </tr>
              <tr>
                  <td width="10" class="tblbgrnd"></td>
                  <td height="18" class="tblbgrnd"><span class="courier"><xsl:value-of select="stdata/header/addressline2"/></span></td>
                  <td height="18"></td>
                  <td class="tblbgrnd"></td>
                  <td height="18" class="tblbgrnd"><span class="courier"><xsl:value-of select="stdata/header/account"/></span></td>
              </tr>
              <tr>
                  <td width="10" class="tblbgrnd"></td>
                  <td height="18" class="tblbgrnd"><span class="courier"><xsl:value-of select="stdata/header/addressline3"/></span></td>
                  <td></td>
                  <td class="tblbgrnd"></td>
                  <td height="18" class="tblbgrnd"><span class="stHeading"><xsl:value-of select="stdata/header/text2"/></span><img src="images/spacer.gif" width="30" height="1" alt="" /><span class="courier"><xsl:value-of select="stdata/header/period"/></span></td>
              </tr>
              <tr>
                  <td width="10" class="tblbgrnd"></td>
                  <td height="18" class="tblbgrnd"><span class="courier"><xsl:value-of select="stdata/header/addressline4"/></span></td>
                  <td></td>
                  <td class="tblbgrnd"></td>
                  <td height="18" class="tblbgrnd"></td>
              </tr>
          <tr>
                <td width="10" class="tblbgrnd"></td>
                <td class="tblbgrnd">
                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                          <td class="tblbgrnd"><span class="courier"><xsl:value-of select="stdata/header/addressline5"/></span></td>
                          <td class="tblbgrnd"><div align="right" class="courier"><xsl:value-of select="stdata/header/rspacer"/><img src="images/spacer.gif" width="10" height="1" alt="" /></div></td>
                        </tr>
                    </table>
                  </td>
                  <td></td>
                  <td class="tblbgrnd"></td>
                  <td class="tblbgrnd"><span class="stHeading">Page <xsl:value-of select="stdata/header/text3"/></span><img src="images/spacer.gif" width="120" height="1" alt="" /><span class="stHeading">Stm # </span><span class="courier"><xsl:value-of select="stdata/header/statnumber"/></span></td>
              </tr>
              <tr>
                  <td width="10" class="tblbgrnd"></td>
                  <td class="tblbgrnd"></td>
                  <td><img src="images/spacer.gif" width="30" height="15" alt="" /></td>
                  <td class="tblbgrnd"></td>
                  <td class="tblbgrnd"></td>
              </tr>
            </table>
            <br />
            <table width="92%" height="700" border="0" align="center" cellpadding="3" cellspacing="0">
          <tr>
                <th class="tblhdrbgrnd">DATE<br />D/M</th>
                <th class="tblhdrbgrnd">REF.</th>
                  <th width="210" class="tblhdrbgrnd" nowrap="nowrap">DESC</th>
                  <th class="tblhdrbgrnd" nowrap="nowrap">AMOUNT<br />(Withdrawal)</th>
                  <th class="tblhdrbgrnd" nowrap="nowrap">UNT<br />(Deposit)</th>
                  <th class="tblhdrbgrnd" nowrap="nowrap">BAL</th>
                  <th class="tblhdrbgrndtr"></th>
          </tr>
          <tr>
                  <td height="4" class="tblhdrruler"></td>
                  <td class="tblhdrruler"></td>
                  <td class="tblhdrruler"></td>
                  <td class="tblhdrruler"></td>
                  <td class="tblhdrruler"></td>
                  <td class="tblhdrruler"></td>
                  <td class="tblhdrrulerr"></td>
          </tr>
          <xsl:for-each select="stdata"><!-- Repeat statement body data -->
          <tr valign="top">
                  <xsl:choose>          
                    <xsl:when test="date1='.'">
                        <td class="tblcellbgrnd" ><img src="images/spacer.gif" width="10" height="1" alt="" /></td>
                        <td class="tblcellbgrnd"></td>
                      <td class="tblcellbgrnd" nowrap="nowrap"></td>
                      <td class="tblcellbgrnd"></td>
                      <td class="tblcellbgrnd"></td>
                      <td class="tblcellbgrnd" nowrap="nowrap"></td>
                      <td class="tblcellbgrndr"></td>
                    </xsl:when>          
                    <xsl:otherwise>
                        <td class="tblcellbgrnd" ><div class="lineh"><div align="right" class="data"><xsl:value-of select="date1"/></div></div></td>
                        <td class="tblcellbgrnd"><div class="lineh"><div align="right" class="data"><xsl:value-of select="reference"/></div></div></td>
                      <td class="tblcellbgrnd" nowrap="nowrap"><div class="lineh"><span class="data"><xsl:value-of select="description"/></span></div></td>
                      <td class="tblcellbgrnd"><div class="lineh"><div align="right" class="data"><xsl:value-of select="debet"/></div></div></td>
                      <td class="tblcellbgrnd"><div class="lineh"><div align="right" class="data"><xsl:value-of select="credit"/></div></div></td>
                      <td class="tblcellbgrnd" nowrap="nowrap"><div class="lineh"><div align="right" class="data"><xsl:value-of select="total"/></div></div></td>
                      <td class="tblcellbgrndr"></td>  
                    </xsl:otherwise>        
                  </xsl:choose>          
          </tr>
          </xsl:for-each><!-- End of statement body -->
          <tr>
                <td height="100%" valign="top" class="tblcellbgrnd"><div align="center" class="message"><xsl:value-of select="footer1/message1"/><br/><xsl:value-of select="footer1/message2"/><br/><xsl:value-of select="footer1/message3"/><br/><xsl:value-of select="footer1/message4"/><br/><xsl:value-of select="footer1/message5"/></div></td>
                <td class="tblcellbgrnd"></td>
                <td class="tblcellbgrnd"></td>
                <td class="tblcellbgrnd"></td>
                <td class="tblcellbgrnd"></td>
                <td class="tblcellbgrnd"></td>
                <td class="tblcellbgrndr"></td>
          </tr>
          <tr>
                <td height="42" class="tblftrgrnd"></td>
                <td class="tblftrgrnd"></td>
                <td class="tblftrgrnd"></td>
                <td class="tblftrgrnd"></td>
                <td class="tblftrgrnd"></td>
                <td class="tblftrgrnd"></td>
                <td class="tblftrbgrndr"></td>
              </tr>
              </table>
          <p class="footer">Please examine this statement promptly. For questions or clarifications, please contact our<br />Current Account Department at 466-1824 or fax 466-1366 within 30 days.<br /><br /></p>                              
            </td>
        </tr>
    </table>
         
        </xsl:if>
       </xsl:if>
      </xsl:for-each>
      <!-- Prev link for pagination -->
      <xsl:choose>
       <xsl:when test="number($Page)-1 &gt;= 0">&#160;
        <A>
         <xsl:attribute name="href">mbstlast.asp?page=<xsl:value-of select="number($Page)-1"/>&amp;pagesize=<xsl:value-of
select="$PageSize"/></xsl:attribute>
          &lt;&lt;Prev
        </A>
       </xsl:when>
       <xsl:otherwise>
        <!-- display something else -->
       </xsl:otherwise>
      </xsl:choose>
     
      <xsl:if test="$selectedRowCount &gt; 1">
       &#160;<b class="blacktext"><xsl:value-of select="number($Page)+1"/>&#160;of&#160;<xsl:value-of
select="number($selectedRowCount)"/></b>&#160;
      </xsl:if>
               
      <!-- Next link for pagination -->
      <xsl:choose>
       <xsl:when test="number($Page)+1 &lt; number($selectedRowCount)">&#160;
        <A target="myframe">
         <xsl:attribute name="href">mbstlast.asp?page=<xsl:value-of select="number($Page)+1"/>&amp;pagesize=<xsl:value-of
select="$PageSize"/></xsl:attribute>
          Next&gt;&gt;
        </A>
       </xsl:when>
       <xsl:otherwise>
        <!-- display something else -->
       </xsl:otherwise>
      </xsl:choose>
        
</body>
</html>       
          
 </xsl:template>
</xsl:stylesheet>


in the same pageAAA.asp i am getting the paging values like

dim pageval, pagesize
pageval = request.querystring("page")
pagesize = request.querystring("pagesize")
               
                Dim objXML
      Dim objXSL
      Dim strHTML
      
      'Load the XML File
      Set objXML = Server.CreateObject("MSXML2.DOMDocument")
      objXML.async = False
      objXML.load(Server.MapPath("juxml.xml"))
      
      'Load the XSL File
      Set objXSL = Server.CreateObject("MSXML2.DOMDocument")
      objXSL.async = False
      objXSL.load(Server.MapPath("cusheet.xsl"))
      
      ' Transform the XML file using the XSL stylesheet
      strHTML = objXML.transformNode(objXSL)
      
      Set objXML = Nothing
      Set objXSL = Nothing
      
      ' Spit out the resulting HTML... the data comes from the
      ' .xml file, but the formatting of the results depends
      ' completely upon the .xsl file.
      Response.Write strHTML

how can i pass the values to the stylesheet in order to get the next page?
0
Comment
Question by:eaweb
  • 5
  • 4
  • 2
11 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 23630872
You can edit a parameter in an XSL using the function below.

<%
 
' <snip>
 
'Load the XSL File
Set objXSL = Server.CreateObject("MSXML2.DOMDocument")
objXSL.async = False
objXSL.load(Server.MapPath("cusheet.xsl"))
 
EditXSLParam  objXSL, "Page",  pageval
EditXSLParam  objXSL, "PageSize",  pagesize
 
' Transform the XML file using the XSL stylesheet
strHTML = objXML.transformNode(objXSL)
 
' <snip>
 
 
 
Sub EditXSLParam(ByRef oXSL, ByVal sParam, ByVal vValue)
    Dim oNodeList, oNode, bFound
    Set oNodeList = oXSL.documentElement.childNodes
    For each oNode in oNodeList
        If oNode.nodeName = "xsl:param" AND oNode.getAttribute("name") = sParam Then
            oNode.setAttribute "select",vValue
            bFound = True
            Exit For
        End If
    Next
End Sub
 
%>

Open in new window

0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 23631027
Hi, I don't like the approach of using DOM methods to alter the XSLT object.
That is kind of opening a can of worms if your stylesheet gets more complex.
There is a simple way of passing a parameter to an XSLT on calling it
You need to use a template processor for that.
And your parameters need to be global, as they are in your case

I have an example script here.
I have kept this as a pure example.
If you want to use this approach, which I strongly recommend, and you need help implementing it, just ask
The XSLT object needs to be free threaded for this approach, the XML object not necessarily
The xslProc.addParameter is what you are after

  Dim objXML, objXSL, xslTemplate, xslProc, paramVal1, paramVal2
 
   set objXML = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
   objXML.async = false
   objXML.load(Server.MapPath("StageInfo.xml"))
 
   set objXSL = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
   objXSL.async = false
   objXSL.load(Server.MapPath("Stage.xsl"))
 
   set xslTemplate = Server.CreateObject("MSXML2.XSLTemplate")
   xslTemplate.stylesheet = objXSL
   set xslProc = xslTemplate.createProcessor()

     xslProc.addParameter "paramVal1", paramVal1
   xslProc.addParameter "paramVal2", paramVal2

   xslProc.input = objXML
   xslProc.transform()
   Response.Write(xslProc.output)
0
 
LVL 28

Expert Comment

by:sybe
ID: 23631080
> You need to use a template processor for that.

I remember having experimented with that and that there were some problems which made me use DOM to get results. Maybe those problems have been solved with more recent version of MSXML. If they are solved, then of course use the template processor.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:eaweb
ID: 23632035
how can i make below navigation part also as a form in order to submit the page number and page size to mbstlast.asp

<!-- Prev link for pagination -->
      <xsl:choose>
       <xsl:when test="number($Page)-1 >= 0">&#160;
        <A>
         <xsl:attribute name="href">mbstlast.asp?page=<xsl:value-of select="number($Page)-1"/>&amp;pagesize=<xsl:value-of
select="$PageSize"/></xsl:attribute>
          <<Prev
        </A>
       </xsl:when>
       <xsl:otherwise>
        <!-- display something else -->
       </xsl:otherwise>
      </xsl:choose>
     
      <xsl:if test="$selectedRowCount > 1">
       &#160;<b class="blacktext"><xsl:value-of select="number($Page)+1"/>&#160;of&#160;<xsl:value-of
select="number($selectedRowCount)"/></b>&#160;
      </xsl:if>
               
      <!-- Next link for pagination -->
      <xsl:choose>
       <xsl:when test="number($Page)+1 < number($selectedRowCount)">&#160;
        <A target="myframe">
         <xsl:attribute name="href">mbstlast.asp?page=<xsl:value-of select="number($Page)+1"/>&amp;pagesize=<xsl:value-of
select="$PageSize"/></xsl:attribute>
          Next>>
        </A>
       </xsl:when>
       <xsl:otherwise>
        <!-- display something else -->
       </xsl:otherwise>
      </xsl:choose>
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 23632165
lets take one step at the time.
Were you succesfull in passing the pagenumber using a template processor?
0
 

Author Comment

by:eaweb
ID: 23632449
oh sorry gertone. yes the first part went succesfull using your method and i just figure out how to post the form data in xsl:

            <form method="POST" action="mbstlast.asp" target="myframe">

<xsl:element name="input">
<xsl:attribute name="type">hidden</xsl:attribute>
<xsl:attribute name="name">pagerequest</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="number($Page)+1"/></xsl:attribute>
</xsl:element>
<xsl:element name="input">
<xsl:attribute name="type">hidden</xsl:attribute>
<xsl:attribute name="name">pagesize</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="$PageSize"/></xsl:attribute>
</xsl:element>

<xsl:element name="input">
<xsl:attribute name="type">submit</xsl:attribute>
<xsl:attribute name="name">submitButton</xsl:attribute>
<xsl:attribute name="value">Submit</xsl:attribute>
</xsl:element>

</form>

But i also confronting another problem. i am using below code as a default to get the first page, but when sending a new value to view the second page i still get the first page and submittedpageRequest variable keep being 0 and submittedpageTotal 1. What could be here the problem?

submittedpageRequest = Request.Form("pageRequest")
if submittedpageRequest = "" then
submittedpageRequest = 0
end if
submittedpageTotal = Request.Form("pageTotal")
if submittedpageTotal = "" then
submittedpageTotal = 1
end if
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 23632613
I think the problem lies with the case sensitivity of the parameters and their difference in naming
XSLT: pagerequest
ASP: pageRequest

and
XSLT: pagesize
ASP: pageTotal
0
 

Author Comment

by:eaweb
ID: 23632874
i changed all params  but still the same problem

pagerequest
pagesize

when i comment out the default values i get an error
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 23632951
Can you log the value of the parameters?
So from the first page you make a request.
That request ends up from the form created by XSLT in the ASP.
It is important that you write out the values of the parametyers, one way or another.
Then you see the values of these parameters and then you knwo wheither to debug the XSLT or the ASP
0
 

Author Comment

by:eaweb
ID: 23633161
yes got it working! i was missing a "&" in front of pagerequest in the data i was posting

Gettm = "accountUser="&Session("AUPos")&"&accountNumber="&Session("unt")&"&accountBankId="&Session("BIpos")&"&pagerequest="&pagerequest&"&pagesize="&pagesize
                  
      dim xmlhttpls
      set xmlhttpls = server.Createobject("MSXML2.ServerXMLHTTP")
      xmlhttpls.Open "POST",getDatUrl,false
      xmlhttpls.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
      xmlhttpls.send Gettm

getDatUrl = mbstlast.asp in the config file.

thanks
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 23636808
welcome
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question