This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Paging Using XSLT -- Too Many 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@commercequest.com
New Phone # 813-639-6478
---------------------------------------------------------------


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]