|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I'm trying to sort a list of performances by date. Unfortunately, they do not have a common parent. Instead, my XML code looks like this:
Code:
<season> <concert id="1"> <foo></foo> <bar></bar> <performance id="11"> <begin>2003-08-18 16:00:00</begin> </performance> <performance id="12"> <begin>2003-08-20 12:00:00</begin> </performance> </concert> <concert id="2"> <foo></foo> <bar></bar> <performance id="13"> <begin>2003-08-16 12:00:00</begin> </performance> </concert> </season> I want to output a list in chronological order by performance/begin that looks like this: Code:
concert performance time 2 13 2003-08-16 12:00:00 1 11 2003-08-18 16:00:00 1 12 2003-08-20 12:00:00 What is the best approach to doing this? At this point, i'm not even sure if I'm going the right way with <xsl:copy-of /> or if I should be working with groupings etc. Any point in the right direction would be helpful. Thank you! |
|
#2
|
|||
|
|||
|
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:template match="/"> <table> <tr><td>Concert</td><td>Performance</td><td>Time</td></tr> <xsl:for-each select="//begin"> <xsl:sort/> <tr> <td><xsl:value-of select="ancestor::concert/@id"/></td> <td><xsl:value-of select="parent::performance/@id"/></td> <td><xsl:value-of select="."/></td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Sorting across various levels |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|