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

Paging Using XSLT -- Too Many Unknowns

Subject: Paging Using XSLT -- Too Many Unknowns
From: Bharat.Chintapally@xxxxxxxxxxxxxxxxx
Date: Tue, 7 Nov 2000 11:50:41 -0500
too many user unknowns
Hi:
     I am trying to use XSLT to present some XML data in HTML tables. I
need to implement a paging mechanism to let users navigate to previous and
next pages etc. I came up with something like the following but I have the
following few(?) questions. Sorry for posting this long mail, but any help
or pointers are really appreciated.

   I am unable to set the scope of the <xsl:param>, I would like to set the
   scope to global and be able to change it from my script when the user
   clicks on the next or previous buttons
   In the client side script how do I set the param on the xslt processor,
   I could not find any useful examples in the xmlsdk samples.
   Am I doing it right?

Original XML document:

 <?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="Test.xsl" ?>
<Status xmlns:HTML="http://www.w3.org/Profiles/XHTML-transitional">
     <Data>
     <Uow uuid="345"><senderId>BNBN</senderId><docId>2</docId></Uow>
     <Uow uuid="678"><senderId>AMZN</senderId><docId>3</docId>
     </Uow><Uow uuid="910"><senderId>EBAY</senderId><docId>4</docId></Uow>
     <Uow uuid="999"><senderId>INDUS</senderId><docId>5</docId></Uow>
     </Data>
</Status>

Original stylesheet:
<xsl:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform" xmlns:HTML
="http://www.w3.org/Profiles/XHTML-transitional">
<xsl:template match="/">
  <xsl:variable name="maxItemsPage" select="2"/>

  <HTML>
      <HEAD>
        <SCRIPT language="JavaScript"><xsl:comment><![CDATA[

          function displayPage(from, to) {
            //Need to set the params to $to and $from
     source = new ActiveXObject("MSXM3.FreeThreaderDOMDocument");
            var s = document.XSLDocument.selectSingleNode("*/xsl:template
[@match='Data']//xsl:apply-templates");
            var d = document.XMLDocument.selectSingleNode("Status/Data");
            Table.innerHTML = d.transformNode(document.XSLDocument);
          }

          function sort(key) {
            var s = document.XSLDocument.selectNodes("*/xsl:template[@match
='Data']//xsl:apply-templates/@order-by");
            for (var i = s.nextNode(); i != null; i = s.nextNode()){
                i.value = key;
            }
            var d = document.XMLDocument.selectSingleNode("Status/Data");
            Table.innerHTML = d.transformNode(document.XSLDocument);
          }

        ]]></xsl:comment></SCRIPT>
      </HEAD>

      <BODY>
        <TABLE WIDTH="100%" BORDER="1" CELLSPACING="1">
        <TR>
        <TD colspan="3"><DIV id="Table">
                <!--<xsl:apply-templates select="Status/Data" order-by
="docId"/>-->
                <xsl:apply-templates select="Status/Data"/>
         </DIV></TD>
        </TR>
        </TABLE>
        <P/>
      </BODY>
    </HTML>
  </xsl:template>

<xsl:template match="Data">
  <xsl:variable name="from" select="1"/>
  <xsl:variable name="to" select="2"/>
  <xsl:call-template name="tableheader"/>
  <xsl:apply-templates select="//Uow[position() &gt;= $from and position()
&lt;=$to]"/>
  <xsl:call-template name="pagefooter"/>
</xsl:template>

<xsl:template name="tableheader">
      <TR>
        <th><A href="javascript:sort('senderId')">Sender ID</A></th>
        <th><A href="javascript:sort('docId')">Document Id</A></th>
      </TR>
</xsl:template>

<xsl:template name="pagefooter">
  <xsl:variable name="from" select="1"/>
  <xsl:variable name="to" select="2"/>
      <TR>
          <th><a href="javascript:displayPage({$from - 2}, {$from -
1})">Back</a></th>
          <th><a href="javascript:displayPage({$to + 1}, {$to +
2})">Next</a></th>
      </TR>
</xsl:template>

<xsl:template match="Uow">
   <tr>
        <td><xsl:value-of select="senderId"/></td><td><xsl:value-of select
="docId"/></td>
  </tr>
</xsl:template>

</xsl:stylesheet>

Thanks
--bharat
---------------------------------------------------------------
Bharat Chintapally
CommerceQuest Inc.
bharat.chintapally@xxxxxxxxxxxxxxxxx
New Phone # 813-639-6478
---------------------------------------------------------------


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.