[jdom-interest] Sorting Question

kevin.schmidt at convergys.com kevin.schmidt at convergys.com
Mon Nov 26 08:51:39 PST 2001



Even though I love XML, I'm not a big fan of XSL.  Even though it has some
easy things, I think overall it is a very clumsy language.  I wrote the
sort the long way, using the Comparable interface, for anyone who wants to
see it.  Perhaps one of the JDOM gurus out there could take it and make it
more generic and include it into the JDOM spec?

(See attached file: SortElementsByName.java)(See attached file:
SortXML.java)

     -Kevin Schmidt
     Cincinnati, OH






Ian Lea <ian.lea at blackwell.co.uk>@pluto.blackwell.co.uk on 11/26/2001
10:30:51 AM

Sent by:  tril at pluto.blackwell.co.uk


To:   kevin.schmidt at convergys.com
cc:   jdom-interest at jdom.org
Subject:  Re: [jdom-interest] Sorting Question


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



--

NOTICE:  The information contained in this electronic mail transmission is
intended by Convergys Corporation for the use of the named individual or
entity to which it is directed and may contain information that is
privileged or otherwise confidential.  If you have received this electronic
mail transmission in error, please delete it from your system without
copying or forwarding it, and notify the sender of the error by reply email
or by telephone (collect), so that the sender's address records can be
corrected.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SortElementsByName.java
Type: application/octet-stream
Size: 1037 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20011126/0e731f9d/SortElementsByName.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SortXML.java
Type: application/octet-stream
Size: 2456 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20011126/0e731f9d/SortXML.obj


More information about the jdom-interest mailing list