[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] [no subject]
How to automate updating the value of a param for the selected outputs Dear All; I needs some advice from you to help me write a xslt for following tasks. The problem is like this; say, there are 20 lines in the xml and 5 lines can be isplayed for the given page number. The page number ,pageno, is defined using <xsl:param name="pageno" select="1"/>. The output is done by calling a named template with the pageno named param. I hope to be able to use prev and next link to automate updating the value of the pageno and calling the named template for the sequential output. I have tried some suggestions from the xsl-list archived records, and could not work out this specific task. The xml and xsl is listed for your information. Any suggestion to the xslt will be much appreciated. == xsl == <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes" /> <xsl:param name="maxline" select="5"/> <xsl:param name="pageno" select="2"/> <xsl:template match="/"> <SCRIPT language="JScript"><xsl:comment> <![CDATA[ var XSLTDOM; function movenext() { XSLTDOM = new ActiveXObject('Msxml2.FreeThreadedDOMDocument'); // XSLTDOM = document.all['XSLDocument']; XSLTDOM.async = false; XSLTDOM.load('pageno.xsl'); var s = XSLTDOM.selectSingleNode("//xsl:param[@name ='pageno']/@select"); alert(s.value); var str1; str1 = parseInt(s.value) + 1; alert(str1); s.value=str1; } ]]> </xsl:comment></SCRIPT> <html> <title>variable page number test</title> <head></head> <body> <xsl:call-template name="printLine"> <xsl:with-param name="pageno" select="$pageno"/> </xsl:call-template> </body> </html> </xsl:template> <xsl:template name="printLine"> <xsl:param name="pageno"/> <table cellspacing="0" cellpadding="2" width="100%" style="border-right:0px;"> <tr><td></td><td align="center" nowrap="" style="border-left:0px;">page no:<xsl:value-of select="$pageno"/></td></tr> <tr><td align="left" nowrap="" style="border-left:0px;"><xsl:if test="$pageno > 1"><a><xsl:attribute name="href">?pageno=<xsl:value-of select="3"/></xsl:attribute><<--Prev</a></xsl:if></td> <!-- what should I do using href here to get the previous pageno and activate the named template to display solutions? --> <xsl:variable name="s2" select="$pageno * $maxline"/> <xsl:variable name="total" select="count(//item)"/> <td align="right" nowrap="" style="border-left:0px;"><xsl:if test="$s2 < $total"><a href="javascript:movenext();">Next-->></a></xsl:if></td></tr> <!-- I need help to be able to move pageno by 1 and acivate the named template, "printLine"--> </table> <table> <xsl:apply-templates select="//line"> <xsl:with-param name="endLine" select="$s2"/> <xsl:with-param name="startLine" select="$s2 - $maxline"/> </xsl:apply-templates> </table> </xsl:template> <xsl:template match="line"> <xsl:param name="endLine"/> <xsl:param name="startLine"/> <xsl:for-each select="item"> <xsl:if test="position() > $startLine and position() <= $endLine"> <tr> <td> <xsl:value-of select="position()"/> </td> <td> <xsl:value-of select="."/> </td> </tr> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> == xml <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="pageno.xsl"?> <line> <item>Item1</item> <item>Item2</item> <item>Item3</item> <item>Item4</item> <item>Item5</item> <item>Item6</item> <item>Item7</item> <item>Item8</item> <item>Item9</item> <item>item10</item> <item>Item11</item> <item>Item12</item> <item>Item13</item> <item>Item14</item> <item>item15</item> .. </line> Sun-fu Yang sfyang@xxxxxxxxxxxxx ~ eMail : SFYang@xxxxxxxxxxxxx UniSVR Global Information Technology Corporation, XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|