I have created 4 tables of data in a xsl stylesheet and
have 2 different templates that are used in displaying these
tables.

On load the two templates are applied properly.

When the sort is called the resulting 4 tables are returned applying
only the default template and not the 2 that were applied during
the original page load.

How can I get the second template to apply after calling the sort
function? I would like to do this with only one stylesheet and
only using xsl.

Below are my xml and xsl files.


xmlfile-------------------------------------------------------



<?xml version="1.0"?>
<?xml:stylesheet type="text/xsl" href="stock6.xsl"?>
<Clients>
<date>1998-10-13T15:56:00</date>
<description>Best and Worst Clients</description>
<Broker>
<Symbol>AOL</Symbol>
<FIFO>NY</FIFO>
<Rebate>56</Rebate>
<Net>47</Net>
</Broker>
<Broker>
<Symbol>CSCO</Symbol>
<FIFO>NA</FIFO>
<Rebate>23</Rebate>
<Net>21</Net>
</Broker>
<Broker>
<Symbol>MSFT</Symbol>
<FIFO>ny</FIFO>
<Rebate>56</Rebate>
<Net>34</Net>
</Broker>
<Broker>
<Symbol>NET</Symbol>
<FIFO>ny</FIFO>
<Rebate>45</Rebate>
<Net>30</Net>
</Broker>
<Broker>
<Symbol>JAK</Symbol>
<FIFO>ny</FIFO>
<Rebate>67</Rebate>
<Net>60</Net>
</Broker>
</Clients>




xslstylesheet--------------------------------------------------------------

<?xml version="1.0"?>



<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">


<xsl:template match="/">
<HTML>
<HEAD>
<title>nothing</title>
<STYLE>
BODY {margin:0}
.bg {font:8pt Verdana; background-color:white; color:black}

H1 {font:bold 14pt Verdana; width:100%; margin-top:1em}
.row {font:8pt Verdana; border-bottom:1px solid #003366}
.header {font:bold 9pt Verdana; cursor:hand; padding:2px; border:0px
outset blue}
.up {background-color:#DDAADD;}
.down {background-color:#FFAADD;}
</STYLE>
</HEAD>




<SCRIPT><xsl:comment><![CDATA[
var stylesheet = null;
var source = null;
var sortField = null;
var ord = null;
function sort(field, datatype)
{

if (ord == "ascending")
sortField.setAttribute("order", "ascending");
else
sortField.setAttribute("order", "descending");

sortField.setAttribute("select", field);
sortField.setAttribute("data-type", datatype);
listinga.innerHTML = source.documentElement.transformNode(stylesheet);
listingb.innerHTML = source.documentElement.transformNode(stylesheet);

listingc.innerHTML = source.documentElement.transformNode(stylesheet);
listingd.innerHTML = source.documentElement.transformNode(stylesheet);

if(ord == "ascending")
ord = "descending";
else
ord = "ascending";

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

<SCRIPT for="window" event="onload"><xsl:comment><![CDATA[
stylesheet = document.XSLDocument;
source = document.XMLDocument;
sortField = document.XSLDocument.selectSingleNode("//xsl:sort[@select='Symbol']");

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


<BODY>
<TABLE width="100%" cellspacing="0" border="0">
<TR>

<TD class="bg"><img src="kcm153x60.gif"> </img></TD>
<TD class="bg">


<img src="reportstxt2.gif" align="bottom"></img><img src="reportlogopic.gif"
align="right"></img> </TD>
</TR>
<TR>
<TD class="bg" width="120" valign="top">
<P>Click on the column headers to sort by that field.</P>
</TD>
<TD class="bg" valign="top">
<h1> Bunch o' Data</h1>
<img src="bar.gif" alt=""></img>
<DIV id="listinga"><xsl:apply-templates select="Clients"/></DIV>
<div id="listingb"><xsl:apply-templates select="Clients"/></div>
</TD>
</TR>

<tr>
<td></td>
<td>
<h1> Bunch o' Data</h1>
<img src="bar.gif" alt=""></img>
<div id="listingc"><xsl:apply-templates select="Clients"/></div>
<div id="listingd"><xsl:apply-templates mode="A" select="Clients"/></div>
</td>
</tr>

</TABLE>
</BODY>
</HTML>
</xsl:template>





<xsl:template priority="-.5" match="Clients" >

<TABLE STYLE="background-color:white" align="left" border="0">
<THEAD>
<TD width="60"><DIV class="header" title="Ticker Symbol" onClick="sort('Symbol',
'text')"><font onmouseout="color='#003366'" onmouseover="color='red'" color="#003366">Symbol</font></DIV></TD>
<TD width="60"><DIV title="FIFO(Gross)" class="header" onClick="sort('FIFO',
'text')"><font onmouseout="color='#003366'" onmouseover="color='red'" color="#003366">FIFO</font></DIV></TD>
<TD width="60"><DIV title="Rebate" class="header" onClick="sort('Rebate',
'number')"><font onmouseout="color='#003366'" onmouseover="color='red'" color="#003366">Rebate</font></DIV></TD>
<TD width="60"><DIV title="Net = FIFO - Rebate" class="header"
onClick="sort('Net', 'number')"><font onmouseout="color='#003366'" onmouseover="color='red'"
color="#003366">Net</font></DIV></TD>
</THEAD>


<xsl:for-each select="Broker">
<xsl:sort select="Symbol" data-type="text"/>

<xsl:if test=" Net &lt; 45">

<TR>
<TD><DIV class="row" style="background-color:blue;color:red"><xsl:value-of
select="Symbol"/></DIV></TD>
<TD><DIV class="row"><xsl:value-of select="FIFO"/></DIV></TD>
<TD><DIV class="row"><xsl:value-of select="Rebate"/></DIV></TD>
<TD><DIV class="row"><xsl:value-of select="Net"/></DIV></TD>
</TR>

</xsl:if>
<xsl:if test=" Net &gt; 46">

<TR>
<TD><DIV class="row" style="color:blue"><xsl:value-of select="Symbol"/></DIV></TD>
<TD><DIV class="row"><xsl:value-of select="FIFO"/></DIV></TD>
<TD><DIV class="row"><xsl:value-of select="Rebate"/></DIV></TD>
<TD><DIV class="row"><xsl:value-of select="Net"/></DIV></TD>
</TR>

</xsl:if>

</xsl:for-each>
</TABLE>




</xsl:template>



<xsl:template priority="0" match="Clients" mode="A">



<TABLE STYLE="background-color:blue" align="left" border="0">
<THEAD>
<TD width="60"><DIV class="header" title="Ticker Symbol" onClick="sort('Symbol',
'text')"><font onmouseout="color='#003366'" onmouseover="color='red'" color="#003366">Symbol</font></DIV></TD>
<TD width="60"><DIV title="FIFO(Gross)" class="header" onClick="sort('FIFO',
'text')"><font onmouseout="color='#003366'" onmouseover="color='red'" color="#003366">FIFO</font></DIV></TD>
<TD width="60"><DIV title="Rebate" class="header" onClick="sort('Rebate',
'number')"><font onmouseout="color='#003366'" onmouseover="color='red'" color="#003366">Rebate</font></DIV></TD>
<TD width="60"><DIV title="Net = FIFO - Rebate" class="header"
onClick="sort('Net', 'number')"><font onmouseout="color='#003366'" onmouseover="color='red'"
color="#003366">Net</font></DIV></TD>
</THEAD>


<xsl:for-each select="Broker">
<xsl:sort select="Symbol" data-type="text"/>

<xsl:if test=" Net &lt; 35">

<TR>
<TD><DIV class="row" style="color:red"><xsl:value-of select="Symbol"/></DIV></TD>
<TD><DIV class="row"><xsl:value-of select="FIFO"/></DIV></TD>
<TD><DIV class="row"><xsl:value-of select="Rebate"/></DIV></TD>
<TD><DIV class="row"><xsl:value-of select="Net"/></DIV></TD>
</TR>

</xsl:if>
<xsl:if test=" Net &gt; 35">

<TR>
<TD><DIV class="row" style="color:blue"><xsl:value-of select="Symbol"/></DIV></TD>
<TD><DIV class="row"><xsl:value-of select="FIFO"/></DIV></TD>
<TD><DIV class="row"><xsl:value-of select="Rebate"/></DIV></TD>
<TD><DIV class="row"><xsl:value-of select="Net"/></DIV></TD>
</TR>

</xsl:if>

</xsl:for-each>
</TABLE>
</xsl:template>


</xsl:stylesheet>