I knocked this up the other day - wonder if others might find it useful?
Maybe even add it to the "build workflow" and include the output in the build?
Its a xlst which transforms the Games.xml into dat file which can be loaded into clrmamepro.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<datafile>
<header>
<name>Supermodel</name>
<description>Supermodel</description>
<category>Emulation</category>
<clrmamepro/>
</header>
<xsl:for-each select="*/game">
<machine>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<description><xsl:value-of select="identity/title"/>-<xsl:value-of select="identity/version"/></description>
<xsl:for-each select="./roms/region[*]/file">
<rom>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:attribute name="crc">
<xsl:value-of select="@crc32"/>
</xsl:attribute>
</rom>
</xsl:for-each>
</machine>
</xsl:for-each>
</datafile>
</xsl:template>
</xsl:stylesheet>
If you want to try it out, navigate to
https://xslttest.appspot.com/
In the top box - you can either
* copy'n'paste the contents of your games.xml file, or
* enter url to the "raw view" on github eg https://raw.githubusercontent.com/trzy/ ... /Games.xml
Copy'n'paste the xlst code above into the 2nd box
Click the "run transformation" button.
Hopefully the results box gets populated. You can then copy the contents into a new file and then load that into clrmamepro.
NB On clrmamepro import - You'll get a warning about duplicate description of "Magical Truck Adventure-Japan" - I just accepted the "Description will be changed to 'Magical Truck Adventure-Japan_0'!"
I'm producing
<machine name="magtruck">
<description>Magical Truck Adventure-Japan</description>
<machine name="mgtrkbad">
<description>Magical Truck Adventure-Japan</description>
I suppose the resulting zips are a "split set" - but skim reading the loading code/trying to run a few of the "clone games" (which have the "parent" in the game.xml) - all seem to load ok - nothing printed to console to say nothing was found.
Notes
I haven't really done much with xslst before so might well be better ways to do this.
I've only run it on the latest games.xml from github - I have no idea if xml has changed between versions
Hope someone find this useful?