[jdom-interest] Sorting Question
    Ian Lea 
    ian.lea at blackwell.co.uk
       
    Mon Nov 26 07:30:51 PST 2001
    
    
  
How about using XSLT with a couple of <xsl:sort> elements?
<xsl:for-each select="Artist">
 <xsl:sort select="@name"/>
 ...
 <xsl:for-each select="Album">
  <xsl:sort select="@name"/>
  ...
  </xsl:for-each>
</xsl:for-each>
Just a thought, perhaps triggered by the fact that I've just
been writing some XSL stylesheets.
--
Ian.
ian.lea at blackwell.co.uk
kevin.schmidt at convergys.com wrote:
> 
> I would like to have my XML file sorted in alphanumeric order by a given
> attribute.
> I would like to sort Artists and Albums by their name attribute, so, for
> example,
> 
> <Artist name="Metallic">
>      <Album name="Master of Puppets"/>
>      <Album name="Load"/>
> </Artist>
> <Artist name="Aerosmith">
>      <Album name="Toys in the Attic"/>
>      <Album name="Draw the Line"/>
> </Artist>
> 
> would become:
> 
> <Artist name="Aerosmith">
>      <Album name="Draw the Line"/>
>      <Album name="Toys in the Attic"/>
> </Artist>
> <Artist name="Metallic">
>      <Album name="Load"/>
>      <Album name="Master of Puppets"/>
> </Artist>
> 
> I was thinking of using the Comparable interface for the Element class, but
> it seems like a lot of work and am wondering if there is an easier way.
>      -Kevin Schmidt
>      Senior Web Developer
>      Cincinnati, OH
    
    
More information about the jdom-interest
mailing list