M
Matt B
Can somebody help me with this please...
I have an xml file along the lines of
<results>
<result status="Pass">
<person name="Fred"/>
<subject name="English" />
</result>
<result status="Pass">
<person name="Harry"/>
<subject name="Maths" />
</result>
<result status="Fail">
<person name="Fred"/>
<subject name="History" />
</result>
<result status="Fail">
<person name="Harry"/>
<subject name="English" />
</result>
<result status="Pass">
<person name="Fred"/>
<subject name="Maths" />
</result>
<result status="Pass">
<person name="Harry"/>
<subject name="History" />
</result>
</results>
And need to generate html for all result staus="Passes" sorted and displayed
like this:
Passes:
Name Subject
------ --------
Fred English
- Maths
Harry History
- Maths
My best attempt so far is:
....
<xsl:for-each select="results/result[@status='Pass']">
<xsl:sort select="person/@name"/>
<tr>
<td>
<xsl:value-of select="person/@name"/>
<xsl:value-of select="subject/@name"/>
</td>
</tr>
</xsl:for-each>
....
Which gives:
Passes:
Name Subject
------ --------
Fred English
Fred Maths
Harry History
Harry Maths
The problems as I see it are that the output is a sub-set af the whole data,
and it is sorted.
Any ideas on how to remove the duplicate entries in the first column would
be very welcome.
I have an xml file along the lines of
<results>
<result status="Pass">
<person name="Fred"/>
<subject name="English" />
</result>
<result status="Pass">
<person name="Harry"/>
<subject name="Maths" />
</result>
<result status="Fail">
<person name="Fred"/>
<subject name="History" />
</result>
<result status="Fail">
<person name="Harry"/>
<subject name="English" />
</result>
<result status="Pass">
<person name="Fred"/>
<subject name="Maths" />
</result>
<result status="Pass">
<person name="Harry"/>
<subject name="History" />
</result>
</results>
And need to generate html for all result staus="Passes" sorted and displayed
like this:
Passes:
Name Subject
------ --------
Fred English
- Maths
Harry History
- Maths
My best attempt so far is:
....
<xsl:for-each select="results/result[@status='Pass']">
<xsl:sort select="person/@name"/>
<tr>
<td>
<xsl:value-of select="person/@name"/>
<xsl:value-of select="subject/@name"/>
</td>
</tr>
</xsl:for-each>
....
Which gives:
Passes:
Name Subject
------ --------
Fred English
Fred Maths
Harry History
Harry Maths
The problems as I see it are that the output is a sub-set af the whole data,
and it is sorted.
Any ideas on how to remove the duplicate entries in the first column would
be very welcome.