PDA

View Full Version : XML Sorting Question



EVEGames
10-30-2008, 05:44 PM
I know I'm in the minority here, but I'm still opting to manually update MAME.xml each time I download new themes. I have a question related to this. Is there an easy (or even difficult) way to automatically sort MAME.xml by the Description field?

I have no experience with XML whatsoever, but I have begun learning about .XSLT files. The problem is, using an xslt sort seems to result in plain unformatted text. What I want is just to sort MAME.xml by the Description field and have it come out in the same format.
For what it's worth, here's the xslt sort I've been playing with:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<menu>
<xsl:for-each select="menu/game">
<xsl:sort select="description"/>
<game>
<name><xsl:value-of select="name"/></name>
<description><xsl:value-of select="description"/></description>
<crc><xsl:value-of select="crc"/></crc>
<manufacturer><xsl:value-of select="manufacturer"/></manufacturer>
<year><xsl:value-of select="year"/></year>
<genre><xsl:value-of select="genre"/></genre>
</game>
</xsl:for-each>
</menu>
</xsl:template>

</xsl:stylesheet>

...the sort seems to work perfectly, but the result is an unformatted plain text file with no XML tags around it. Are there any freeware XML sort programs out there that can sort on specific XML fields, and result in a formatted XML file? :questionmark:
Just to be clear, I do know about the themes_only option, I just don't want to use it.

Aabra
10-30-2008, 07:07 PM
I just load up the *old* HyperHQ (not the new one that work has just started on) and use that to sort the list.

The Loafer
10-30-2008, 07:55 PM
Yeah, but I'm not sure you can sort by "description" only by "name/title". Check it out though.

Aabra
10-30-2008, 08:20 PM
The old HyperHQ sorts by Description. It doesn't sort by name.

The rom pingpong gets put in with the letter K, because the description is "Konami's Ping Pong".

So while there are a couple weird instances of that... plus the Street Fighter and Super Street Fighter games getting separated..... on the whole it's pretty good.

EVEGames
10-30-2008, 08:30 PM
PERFECT! Thanks Aabra and Loaf, I forgot about the old HyperHQ! Problem solved. Thanks given! :beer: