Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

How Do I Get an XSL Application to Page The Output of the Records Displayed?+

Hello Gertone:

In an earlier discussion...

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XML/Q_23856726.html#a22829616

I received assistance in creating a web application that would "page" the number of records displayed. That is, the after displaying 15 records, the app would pause and display PREVIOUS and NEXT buttons to guide the user back and forth through the data.

You provided me with the basics of this system and thus far I have a system that does exactly that - it pauses after the first 15 records have been displayed. But, I still cannot move to the next page. There must be a bug somewhere. I am know re-posting the XSLT code for your review.

Do you have any idea what must be changed to get the next page to appear (and once there, move to the previous group of 15 records)?

Thanks for all your help so far.
0
gbmcneil
Asked:
gbmcneil
  • 14
  • 10
1 Solution
 
gbmcneilAuthor Commented:
Here is the XSL code thus far -
<?xml version="1.0" encoding="UTF-8"?>
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output indent="yes" method="html"/>
    <xsl:param name="price">All</xsl:param>
    <xsl:param name="sector">All</xsl:param>
    <xsl:param name="sort">EquityName</xsl:param>
    <xsl:param name="first">1</xsl:param>
    <xsl:param name="page">15</xsl:param>
   
   
    <xsl:variable name="low-price-level">
        <xsl:choose>
            <xsl:when test="$price = 'All'">00.00</xsl:when>
            <xsl:when test="$price = '49'">00.00</xsl:when>
            <xsl:when test="$price = '99'">00.49</xsl:when>
            <xsl:when test="$price = '999'">00.99</xsl:when>
            <xsl:when test="$price = '1000'">9.99</xsl:when>
        </xsl:choose>
    </xsl:variable>
    
    <xsl:variable name="high-price-level">
        <xsl:choose>
            <xsl:when test="$price = 'All'">99999999999999999999999999999999.99</xsl:when>
            <xsl:when test="$price = '49'">00.50</xsl:when>
            <xsl:when test="$price = '99'">02.00</xsl:when>
            <xsl:when test="$price = '999'">10.00</xsl:when>
            <xsl:when test="$price = '1000'">99999999999999999999999999999999.99</xsl:when>
        </xsl:choose>
    </xsl:variable>
 
   
    <xsl:variable name="cnt-records">
        <xsl:choose>
            <xsl:when test="$sector = 'All'">
                <xsl:value-of select="count(//Record[Exchange !='XXXX'] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level])"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="count(//Record[Exchange = $sector] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level])"/>
            </xsl:otherwise>
        </xsl:choose>
     </xsl:variable>
   
     <!--
     <H1><xsl:value-of select="$cnt-records"/></H1>
     -->  
   
    <!-- Record select and sort -->
    <xsl:template match="Records">
    
    
    <table border="1" width="500" cellpadding="3" cellspacing="3">
                          
    	<xsl:call-template name="header"/>
	<xsl:choose>
		     	
	     <xsl:when test="$sort='EquityName' and $sector = 'All'">
	         <xsl:apply-templates select="Record[Exchange !='XXXX'] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level] [position() &lt; ($first + $page)]">
	         <xsl:sort select="EquityName" data-type="text" order="ascending"/>
	         </xsl:apply-templates>
	     </xsl:when>
	   
	     <xsl:when test="$sort='EquityName' and $sector != 'All'">
	         <xsl:apply-templates select="Record[Exchange = $sector] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level] [position() &lt; ($first + $page)]">
	         <xsl:sort select="EquityName" data-type="text" order="ascending"/>
	         </xsl:apply-templates>
	     </xsl:when> 
	   
	     <xsl:when test="$sort='EndPrice' and $sector = 'All'">
	         <xsl:apply-templates select="Record[Exchange !='XXXX'] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level] [position() &lt; ($first + $page)]">
	         <xsl:sort select="EndPrice" data-type="number" order="descending"/>
	         </xsl:apply-templates>
	     </xsl:when>
	   
	     <xsl:when test="$sort='EndPrice' and $sector != 'All'">
	         <xsl:apply-templates select="Record[Exchange = $sector] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level] [position() &lt; ($first + $page)]">
	         <xsl:sort select="EndPrice" data-type="number" order="descending"/>
	         </xsl:apply-templates>
	     </xsl:when>	
	   
	   
	     <xsl:when test="$sort='Change' and $sector = 'All'">
	         <xsl:apply-templates select="Record[Exchange !='XXXX'] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level] [position() &lt; ($first + $page)]">
	         <xsl:sort select="Change" data-type="number" order="descending"/>
	         </xsl:apply-templates>
	     </xsl:when>
	   
	     <xsl:when test="$sort='Change' and $sector != 'All'">
	         <xsl:apply-templates select="Record[Exchange = $sector] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level] [position() &lt; ($first + $page)]">
	         <xsl:sort select="Change" data-type="number" order="descending"/>
	         </xsl:apply-templates>
	     </xsl:when>	
	     
	</xsl:choose>     
	<!--
	<th STYLE="bgcolor:#d4d0c8"></th>
	-->
		
	</table>
	
	
	<div>
	<xsl:variable name="new-first-p">
                <xsl:choose>
                    <xsl:when test="($first - $page - 1) > 1">
                    <xsl:value-of select="$first - $page - 1"/>
                    </xsl:when>
                    <xsl:otherwise>1
                    </xsl:otherwise>
                </xsl:choose>
        </xsl:variable>
        <xsl:variable name="new-first-n">
                <xsl:choose>
                    <xsl:when test="($first + $page) > $cnt-records">
                    <xsl:value-of select="$first"/>
                    </xsl:when>
                    <xsl:otherwise>
                    <xsl:value-of select="$first + $page"/>
                    </xsl:otherwise>
                </xsl:choose>
        </xsl:variable>
  
  	<h3>Navigation Buttons</h3>
        <button type="SUBMIT" name="Prev" value="Prev" onClick="TransF({$price}, {$sector}, {$sort}, {$new-first-p}, {$page});">Prev</button>
        <button type="SUBMIT" name="Next" value="Next" onClick="TransF({$price}, {$sector}, {$sort}, {$new-first-n}, {$page});">Next</button>
        
	</div>
	
	   	    
    </xsl:template>
    
       
    <!-- Header row templates -->
    <xsl:template name="header">
        <tr>
            <th style="color: #000000; text-align: left; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">Symbol</th>	
	    <th style="color: #000000; text-align: left; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">Exchange</th> 	        
            <th style="color: #000000; text-align: left; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">EquityName</th>
            <th style="color: #000000; text-align: right; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">BeginPrice</th>
            <th style="color: #000000; text-align: right; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">EndPrice</th>
            <th style="color: #000000; text-align: right; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">Difference</th>
            <th style="color: #000000; text-align: right; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">Change</th>
        </tr>
    </xsl:template>
     
    <xsl:template match="Record">
        <tr>
            <xsl:if test="Difference &lt; 0">
                <xsl:attribute name="style">
                    <xsl:text>color: #990000;</xsl:text>
                </xsl:attribute>
            </xsl:if>
            <xsl:if test="Difference &gt; 0">
                <xsl:attribute name="style">
                    <xsl:text>color: #006B00;</xsl:text>
                </xsl:attribute>
            </xsl:if> 	
            
            <td><xsl:value-of select="Symbol"/></td>
            
            <td><xsl:value-of select="Exchange"/></td>
               
            <td><xsl:value-of select="EquityName"/></td>
             
            <td style="text-align: right;">
            <xsl:value-of select="format-number(BeginPrice, '#.00')"/></td>
             
            <td style="text-align: right; format-number(. , '#.00')">
            <xsl:value-of select="format-number(EndPrice, '#.00')"/></td>
                         
            <td style="text-align: right; format-number(. , '#.00')">
            <xsl:value-of select="format-number(Difference, '#.00')"/></td>
             
            <td style="text-align: right; format-number(. , '#.00')">
            <xsl:value-of select="format-number(Change, '#.00')"/></td>
         </tr>
    </xsl:template>
    
</xsl:stylesheet>

Open in new window

0
 
gbmcneilAuthor Commented:
And, here is the html that calls the XSL -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Dow Jones for Gordon</title>
         <script language="javascript">
	function TransF(page, first) } 
			// create and load the XML document
			var oXML = new ActiveXObject("Msxml2.DOMDocument");
			oXML.async = false;
			oXML.load("Dow_Stocks_Data.xml");
			// create and load the XSL document
			var oXSL = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
		         oXSL.async = false;
		         oXSL.load("Dow-Stocks.xsl");
                           // create the template processor
                           var oTmpl = new ActiveXObject("Msxml2.XSLTemplate");
         		 oTmpl.stylesheet = oXSL;
		         oProc = oTmpl.createProcessor();
		         oProc.input = oXML;
		         // add parameters
                           oProc.addParameter("price", price);
                           oProc.addParameter("sector", sector);
                           oProc.addParameter("sort", sortseq);
                           oProc.addParameter("page", page);
		         oProc.addParameter("first", first);
		         // make the transform
	   	         oProc.transform();
         		         var resHTM = oProc.output;
         		         // write the transformation result as the inner HTML of the div
         		         document.getElementById("RB").innerHTML = resHTM;
        }
	</script>
</head>
 
<body>
	<div>
		<button type="SUBMIT" name="Button1" value="Button1" onclick="TransF(1,15);">
			<img src="button.gif"/>
		</button>
	</div>
	<div>
		<div id="RB"></div>
	<div>
</body>
</html>

Open in new window

0
 
gbmcneilAuthor Commented:
Gertone -

One thing that I observe is that when the XSL code calls TransF - this function is located in located in the html code.

Now, it is not apparent to me that calling the transform in the html that that links the XSL code in the html program.

The tipoff is that when the XSL code calls the TransF function it does not trigger the alert() that was included for debugging purposes.

Do you think that we should duplicate the TransF function in the XSL file (if that is possible) so it can see this function?


0
Independent Software Vendors: 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!

 
Geert BormansCommented:
I am not sure that I grasp this question completely.
The TransF() is never called in the XSLT.
In the XSLT we create some HTML snippte, that is pulled in, in an <div>
so the serialisation of the resulting HTML has the TransF()
If you call it, it will be from the browser window (unaware of the XSLT) and it should execute the allert()

If you want to "allert" information from your XSLT internals (such as variable values) you should simply output them, so they become visible in the HTML
0
 
gbmcneilAuthor Commented:
Hi Gertone:

Well, it does not execute the alert() referenced in the XSLT when either the PREVIOUS or NEXT buttons are pressed.  And, if the Transf() code is not being executed by depresssing the buttons, there is no way the record list is going to "page".

0
 
gbmcneilAuthor Commented:
Gertone:

Does your version of the code page the data?
0
 
Geert BormansCommented:
pff, I managed to debug the damn thing ...
There are no quotes around the strings in the arguments of the function call,
so the TransF() call has JavaScript erros

This works
          <h3>Navigation Buttons</h3>
          <button type="SUBMIT" name="Prev" value="Prev" onClick="TransF('{$price}', '{$sector}', '{$sort}', {$new-first-p}, {$page});">Prev</button>
          <button type="SUBMIT" name="Next" value="Next" onClick="TransF('{$price}', '{$sector}', '{$sort}', {$new-first-n}, {$page});">Next</button>
          
0
 
gbmcneilAuthor Commented:
Believe it or not I just came to the same conclusion myself. So, there are params that require single quote marks and variables that don't. Pretty challenging I'd say. Let me play with it a little. I think it's time you went to sleep.




0
 
Geert BormansCommented:
Well, the ones I showed in my example don't require quotes,
since they are integers, not cast to string for the function call
price is most of the time an integer too, but you have 'All', so you should add quotes there,
the other two are obvious, they are always strings
anyway, basically you can put quotes around all of them

and yes, I am of to bed now (1AM here)

cheers

Geert
0
 
gbmcneilAuthor Commented:
Good Morning Gertone:

After making sure there was consistency between the calling variables, parameters, and TransF - the "paging" code functions, but in a very strange way. When the NEXT button is pressed the the app will add the next page of data to the bottom of the existing data. The desired way, obviously, is to replace the line items with the current page-full of records.

And when going backwards (by pressing the PREVIOUS button) the code does more or less the same thing. It subtracts the current pageful of records from the existing records that are shown.

This type of functionality becomes most obvious when the number of records in a page (the "$Page" variable is set to 10. That creates the opportunity to see 3 pages (if total number of records is 30), and put a little stress on the PREV and NEXT buttons.

Do you know where the logic would be to display, say, only records "11 to 20" or "21 to 30" - replacing what is currently displayed? Thanks.

Gordo





0
 
Geert BormansCommented:
I will look into this.
Of course, your desired way is the way I intended this to be, so there must be a small bug
0
 
Geert BormansCommented:
This is an interesting bug indeed
I have used the original apply-template sfrom my example (since that was the shorter version)
But it is equal
where you now have
<xsl:apply-templates select="Record[Exchange='NYSE'][position() >= $first][position() < ($first + $page)]">
you should have
<xsl:apply-templates select="Record[Exchange='NYSE'][position() >= $first][position() <= $page]">
or
<xsl:apply-templates select="Record[Exchange='NYSE'][position() >= $first and position() < ($first + $page)]">

it is an interesting example where
[position() >= $first and position() < ($first + $page)]
and
[position() >= $first ][ position() < ($first + $page)]
are not equal

In the second case, the position() in the second predicate, is the position() in the allready selected nodeset,
(so starting from $first)

It is a stupid mistake to make in the first place, but a damn hard one to trace in debugging :-)
0
 
gbmcneilAuthor Commented:
Very Good Gertone -

I would have never found that bug. For the benefit of those following this discussion, I think that we should point up that one of the lines in the "<xsl:apply-templates select" section of code should change to:

<xsl:apply-templates select="Record[Exchange !='XXXX'] [EndPrice > $low-price-level][EndPrice < $high-price-level] [position() >= $first and position() < ($first + $page)]">

and that the "less than the first position plus the page should include a "<" rather than <. The processor often doesn't like the < sign.

Thanks very much again for your contribution.
0
 
Geert BormansCommented:
welcome
0
 
gbmcneilAuthor Commented:
Hello Gertone:

I've made great progress at this end, but still have a bug. Do you have any energy left to look into it?

Gordon
0
 
Geert BormansCommented:
of course, tell me
0
 
gbmcneilAuthor Commented:
Gertone:

There is some very unusual behavior displayed when the sort sequence is defined to be something other than the default (by EquityName) as is the arrangement in the XML file.

For example, if it is desirable to see our little list of Dow Index stocks sorted by their most recent prices (EndPrice), then the processor appears to be breaking down the total number of stocks into the number we've defined per page and sorting each of these two pages separately. So, if the page is defined as having 15 stocks, there end up being two pages (each containing 15 stocks eacg) making up the Dow list.

Now, what appears to be happening is that Page 1 is sorted. Then Page 2 is sorted. Obviously, what is desired is for the records making up Pages 1 and 2 to be sorted all at the sametime and then all displayed in descending order from records 1 thru 15 to records and then 16 thru 30.

I think what is throwing the system off is the steps taken to arrive at the final sort. In the code -

<xsl:when test="$sort='EndPrice' and $sector = 'All'">
         <xsl:apply-templates select="Record[Exchange !='XXXX'] [EndPrice > $low-price-level][EndPrice < $high-price-level] [position() >= $first and position() < ($first + $page)]">
         <xsl:sort select="EndPrice" data-type="number" order="descending"/>
         </xsl:apply-templates>
 </xsl:when>

it seems that a request is being made to select only so many records as are less than the first (position) plus the the number per page. If the "sort" could be done first followed by the "select", one might think that the correct order would result.

Any thoughts?
0
 
Geert BormansCommented:
You are right in your observation, paging happens too early
You should remove th epaging predicate from the apply templates and create a test in the Record template,
since you can't have variables in the predicate of the match attribute,
you will need an if statement

something like this
<xsl:template match="Record">
   <xsl:if test ="position() >= $first and position() < ($first + $page)">
       ... do all that you had previously in your record template ...
   </xsl:if>
</xsl:template>
0
 
gbmcneilAuthor Commented:
Thank you for your help. Let me play with it a little.
0
 
gbmcneilAuthor Commented:
I have removed the record predicate from the <xsl:template match="Records"> section and moved it to the <xsl:template match="Record"> section as as test.

The result does not seem to be any different. My code is shown below.




<!-- Record select and sort -->
    <xsl:template match="Records">
    
    
    <DIV>
    <table border="1" width="500" cellpadding="3" cellspacing="3">
                          
    	<xsl:call-template name="header"/>
	<xsl:choose>
		     	
	     <xsl:when test="$sort='EquityName' and $sector = 'All'">
	         <xsl:apply-templates select="Record[Exchange !='XXXX'] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level] [position() >= $first and position() &lt; ($first + $page)]">
	         <xsl:sort select="EquityName" data-type="text" order="ascending"/>
	         </xsl:apply-templates>
             </xsl:when>
	   
	     <xsl:when test="$sort='EquityName' and $sector != 'All'">
	         <xsl:apply-templates select="Record[Exchange = $sector] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level] [position() >= $first and position() &lt; ($first + $page)]">
	         <xsl:sort select="EquityName" data-type="text" order="ascending"/>
	         </xsl:apply-templates>
	     </xsl:when> 
	   
	     <xsl:when test="$sort='EndPrice' and $sector = 'All'">
	         <xsl:apply-templates select="Record[Exchange !='XXXX'] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level] ">
	         <xsl:sort select="EndPrice" data-type="number" order="descending"/>
	         </xsl:apply-templates>
	     </xsl:when>
	   
	     <xsl:when test="$sort='EndPrice' and $sector != 'All'">
	         <xsl:apply-templates select="Record[Exchange = $sector] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level] ">
	         <xsl:sort select="EndPrice" data-type="number" order="descending"/>
	         </xsl:apply-templates>
	     </xsl:when>	
	   
	   
	     <xsl:when test="$sort='Change' and $sector = 'All'">
	         <xsl:apply-templates select="Record[Exchange !='XXXX'] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level] [position() >= $first and position() &lt; ($first + $page)]">
	         <xsl:sort select="Change" data-type="number" order="descending"/>
	         </xsl:apply-templates>
	     </xsl:when>
	   
	     <xsl:when test="$sort='Change' and $sector != 'All'">
	         <xsl:apply-templates select="Record[Exchange = $sector] [EndPrice > $low-price-level][EndPrice &lt; $high-price-level] [position() >= $first and position() &lt; ($first + $page)]">
	         <xsl:sort select="Change" data-type="number" order="descending"/>
	         </xsl:apply-templates>
	     </xsl:when>	
	     
	</xsl:choose>     
	<!--
	<th STYLE="bgcolor:#d4d0c8"></th>
	-->
		
	</table>
	
	
	<div>
	<xsl:variable name="new-first-p">
                <xsl:choose>
                    <xsl:when test="($first - $page - 1) > 1">
                    <xsl:value-of select="$first - $page"/>
                    </xsl:when>
                    <xsl:otherwise>1
                    </xsl:otherwise>
                </xsl:choose>
        </xsl:variable>
        <xsl:variable name="new-first-n">
                <xsl:choose>
                    <xsl:when test="($first + $page) > $cnt-records">
                    <xsl:value-of select="$first"/>
                    </xsl:when>
                    <xsl:otherwise>
                    <xsl:value-of select="$first + $page"/>
                    </xsl:otherwise>
                </xsl:choose>
        </xsl:variable>
        
        <xsl:variable name="last-number">
        	<xsl:value-of select="$cnt-records mod $page"/>
        </xsl:variable>
        <xsl:variable name="last-first">
    	        <xsl:choose> 
    	            <xsl:when test="$last-number > 0"> 
                    <xsl:value-of select="$cnt-records - $last-number + 1"/>
  	    	    </xsl:when>
  	    	    <xsl:when test="$last-number &lt; 1"> 
                    <xsl:value-of select="$cnt-records - $page + 1"/>
  	    	    </xsl:when>
  	    	    <xsl:otherwise>
                    <xsl:value-of select="0"/>
                    </xsl:otherwise>
  	        </xsl:choose>
        </xsl:variable>
        <xsl:variable name="max-records">
    	        <xsl:choose> 
    	            <xsl:when test="$first + $page - 1 &gt;= $cnt-records"> 
                    <xsl:value-of select="$cnt-records"/>
  	    	    </xsl:when>
  	    	    <xsl:when test="$first + $page - 1 &lt; $cnt-records"> 
                    <xsl:value-of select="$first + $page - 1"/>
  	    	    </xsl:when>
  	    	  	    
  	    	    <xsl:otherwise>
                    <xsl:value-of select="0"/>
                    </xsl:otherwise>
  	        </xsl:choose>
        </xsl:variable>
          
  
        <H4 STYLE="font-family: Arial, Helvetica, Sans-Serif; font-weight: 900; font-size: 11px"><xsl:value-of select="$first"/> to <xsl:value-of select="$max-records"/> of <xsl:value-of select="$cnt-records"/> Record(s) </H4> 
         
        
        <H5 STYLE="position: absolute; top: 103px; left: 525px; font-family: Arial, Helvetica, Sans-Serif; font-weight: 900; font-size: 11px; color:#ffffff"><xsl:value-of select="$first"/> to <xsl:value-of select="$max-records"/> of <xsl:value-of select="$cnt-records"/> Record(s) </H5>         
             
        <!---        
        <H6><xsl:value-of select="$last-first"/></H6>
        -->
      
              
        <button STYLE="font-family: Arial, Helvetica, sans-serif; font-weight: medium; font-size: 11px" type="SUBMIT" name="First" value="First" onClick="TransF('{$price}', '{$sector}', '{$sort}', '{$page}', 1);">First</button>  	
        <button STYLE="font-family: Arial, Helvetica, sans-serif; font-weight: medium; font-size: 11px" type="SUBMIT" name="Prev" value="Prev" onClick="TransF('{$price}', '{$sector}', '{$sort}', '{$page}', {$new-first-p});">Prev</button>
        <button STYLE="font-family: Arial, Helvetica, sans-serif; font-weight: medium; font-size: 11px" type="SUBMIT" name="Next" value="Next" onClick="TransF('{$price}','{$sector}', '{$sort}', '{$page}', {$new-first-n});">Next</button>
        <button STYLE="font-family: Arial, Helvetica, sans-serif; font-weight: medium; font-size: 11px" type="SUBMIT" name="Last" value="Last" onClick="TransF('{$price}', '{$sector}', '{$sort}', '{$page}', {$last-first});">Last</button>  	
        
        </div>
	</DIV>
	
	<button STYLE="position: absolute; top: 102px; left: 370px; font-family: Arial, Helvetica, sans-serif; font-weight: medium; font-size: 11px" type="SUBMIT" name="First" value="First" onClick="TransF('{$price}', '{$sector}', '{$sort}', '{$page}', 1);">First</button>  	
        <button STYLE="position: absolute; top: 102px; left: 401px; font-family: Arial, Helvetica, sans-serif; font-weight: medium; font-size: 11px" type="SUBMIT" name="Prev" value="Prev" onClick="TransF('{$price}', '{$sector}', '{$sort}', '{$page}', {$new-first-p});">Prev</button>
        <button STYLE="position: absolute; top: 102px; left: 434px; font-family: Arial, Helvetica, sans-serif; font-weight: medium; font-size: 11px" type="SUBMIT" name="Next" value="Next" onClick="TransF('{$price}','{$sector}', '{$sort}', '{$page}', {$new-first-n});">Next</button>
        <button STYLE="position: absolute; top: 102px; left: 467px; font-family: Arial, Helvetica, sans-serif; font-weight: medium; font-size: 11px" type="SUBMIT" name="Last" value="Last" onClick="TransF('{$price}', '{$sector}', '{$sort}', '{$page}', {$last-first});">Last</button>  	
        
	  	    
    </xsl:template>
    
       
    <!-- Header row templates -->
    <xsl:template name="header">
        <tr>
            <th style="color: #000000; text-align: left; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">RecNo...</th> 
            <th style="color: #000000; text-align: left; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">Symbol</th>	
	    <th style="color: #000000; text-align: left; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">Exchange</th> 	        
            <th style="color: #000000; text-align: left; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">EquityName</th>
            <th style="color: #000000; text-align: right; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">BeginPrice</th>
            <th style="color: #000000; text-align: right; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">EndPrice</th>
            <th style="color: #000000; text-align: right; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">Difference</th>
            <th style="color: #000000; text-align: right; font-family: Arial, Helvetica ; font-weight: 900; font-size: 11px;">Change</th>
        </tr>
    </xsl:template>
     
    <xsl:template match="Record">
    
        <xsl:if test ="position() >= $first and position() < ($first + $page)"> 
        <tr>
            <xsl:if test="Difference &lt; 0">
                <xsl:attribute name="style">
                    <xsl:text>color: #990000;</xsl:text>
                </xsl:attribute>
            </xsl:if>
            <xsl:if test="Difference &gt; 0">
                <xsl:attribute name="style">
                    <xsl:text>color: #006B00;</xsl:text>
                </xsl:attribute>
            </xsl:if> 	
            
            <td><xsl:value-of select="position() + $first - 1"/></td>
                        
            <td><xsl:value-of select="Symbol"/></td>
            
            <td><xsl:value-of select="Exchange"/></td>
               
            <td><xsl:value-of select="EquityName"/></td>
             
            <td style="text-align: right;">
            <xsl:value-of select="format-number(BeginPrice, '#.00')"/></td>
             
            <td style="text-align: right; format-number(. , '#.00')">
            <xsl:value-of select="format-number(EndPrice, '#.00')"/></td>
                         
            <td style="text-align: right; format-number(. , '#.00')">
            <xsl:value-of select="format-number(Difference, '#.00')"/></td>
             
            <td style="text-align: right; format-number(. , '#.00')">
            <xsl:value-of select="format-number(Change, '#.00')"/></td>
         </tr>
         </xsl:if>
    </xsl:template>
    
</xsl:stylesheet>

Open in new window

0
 
gbmcneilAuthor Commented:
Gertone:

I am still having problems with my app. It will not sort correctly. I have posted my code above which moves the predicate to the Martch Templateb Record section for the situaton where the user is trying to sort by EndPrice. Can you find some time to take a look a it.

Thanks.

Gordo



0
 
Geert BormansCommented:
does it sort correctly without paging?
0
 
gbmcneilAuthor Commented:
If I set the "Lines Per Page" to 30 (which is the entire group of records in the recordset), the sort is correct for all three possible sequences - EquityName, EndPrice, and %Change.

If I set the page to 15 records, EquityName is okay (I think because that is how the collection of records is pre-sorted to begin with). But, when the sequence requested is by EndPrice or %Change, I get two different sorts per selection, one for each page of data.
0
 
Geert BormansCommented:
Hi Gordo,

well, I have tested my suggestion from
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XSLT/Q_23879943.html?cid=748#a22913516
and it works wonderfully well with my code (which is a simplified version of what you must have now)
Theoretically it should anyway

Something must have gone wrong in the implementation of it
I suggest that you post your current XSLT (maybe package the whole thing again, either mail or here) so I can look at it

cheers

Geert
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 14
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now