J
Jarle Presttun
Hi,
Sometimes I display values by combining information from different
sections in the xml, like I do with gradeText in the student template
bellow. Is it possible to sort on gradeText when I loop over students,
as shown in the example? If not, I would have to modify some sql's.
Thanks, Jarle.
XML:
<root>
<grades>
<grade id="0">
<gradeText>A</gradeText>
<gradeValue>6</gradeValue>
</grade>
<grade id="1">
<gradeText>B</gradeText>
<gradeValue>5</gradeValue>
</grade>
<grade id="2">
<gradeText>C</gradeText>
<gradeValue>4</gradeValue>
</grade>
</grades>
<students>
<student>
<name>Peter</name>
<gradeId>2</gradeId>
</student>
<student>
<name>Laura</name>
<gradeId>0</gradeId>
</student>
<student>
<name>John</name>
<gradeId>1</gradeId>
</student>
</students>
</root>
XSL:
<xsl:template match="students">
<table>
<tr>
<td>Name</td>
<td>Grade</td>
</tr>
<xsl:apply-templates select="student">
<!-- Would like to sort on gradeText here -->
</xsl:apply-templates>
</table>
</xsl:template>
<xsl:template match="student">
<xsl:variable name="gradeId" select="gradeId"/>
<tr>
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="/*/grades/grade[@id = $gradeId]/gradeText"/>
</td>
</tr>
</xsl:template>
Sometimes I display values by combining information from different
sections in the xml, like I do with gradeText in the student template
bellow. Is it possible to sort on gradeText when I loop over students,
as shown in the example? If not, I would have to modify some sql's.
Thanks, Jarle.
XML:
<root>
<grades>
<grade id="0">
<gradeText>A</gradeText>
<gradeValue>6</gradeValue>
</grade>
<grade id="1">
<gradeText>B</gradeText>
<gradeValue>5</gradeValue>
</grade>
<grade id="2">
<gradeText>C</gradeText>
<gradeValue>4</gradeValue>
</grade>
</grades>
<students>
<student>
<name>Peter</name>
<gradeId>2</gradeId>
</student>
<student>
<name>Laura</name>
<gradeId>0</gradeId>
</student>
<student>
<name>John</name>
<gradeId>1</gradeId>
</student>
</students>
</root>
XSL:
<xsl:template match="students">
<table>
<tr>
<td>Name</td>
<td>Grade</td>
</tr>
<xsl:apply-templates select="student">
<!-- Would like to sort on gradeText here -->
</xsl:apply-templates>
</table>
</xsl:template>
<xsl:template match="student">
<xsl:variable name="gradeId" select="gradeId"/>
<tr>
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="/*/grades/grade[@id = $gradeId]/gradeText"/>
</td>
</tr>
</xsl:template>