goaway1234
Programmer
I am relatively new to XSLT, so i hope this isn't too noobish.
The task at hand is creating a web page where the result of some transform is displayed in a table, which has column headers that users can click to sort it. What I have is currently working, and for simplicity I removed all but one column and some javascript:
I had to throw in an extraneous <xsl:choose> and commit a copy-paste style crime to sort the data ascending or descending depending on the value of the $sort-direction variable.
Is there any way to store the value of the sort order in a variable and eliminate the xsl:choose element? The most intuitive and clean solution gives a parse error:
The task at hand is creating a web page where the result of some transform is displayed in a table, which has column headers that users can click to sort it. What I have is currently working, and for simplicity I removed all but one column and some javascript:
Code:
<xsl:template match="//current-issues">
<table style="width:100%">
<thead>
<tr>
<td class="clickable" style="text-decoration: underline" id="reportedHeader_{$status}">Reported Date</td>
</tr>
</thead>
<tbody>
<xsl:choose>
<xsl:when test="$sort-direction='ascending'">
<xsl:apply-templates select="current-issues/i">
<xsl:sort data-type="number" select="@reported-sort" order="ascending"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="current-issues/i">
<xsl:sort data-type="number" select="@reported-sort" order="descending"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</tbody>
</table>
</xsl:template>
I had to throw in an extraneous <xsl:choose> and commit a copy-paste style crime to sort the data ascending or descending depending on the value of the $sort-direction variable.
Is there any way to store the value of the sort order in a variable and eliminate the xsl:choose element? The most intuitive and clean solution gives a parse error:
Code:
<xsl:template match="//current-issues">
<table style="width:100%">
<thead>
<tr>
<td class="clickable" style="text-decoration: underline" id="reportedHeader_{$status}">Reported Date</td>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="current-issues/i">
<xsl:sort data-type="number" select="@reported-sort" order="$sort-direction"/>
</xsl:apply-templates>
</tbody>
</table>
</xsl:template>