I found that I can put this to how I want simply by re-ordering the movies.xml file manually. I've been having a go writing an XSLT stylesheet to do the job but I'm a bit stuck. Wondered if anyone here might know their stuff better than me.
Below is what I've managed so far. The output of this is the films subsection of the XML file, ordered into strict alphabetical order. At present, I have to manually cut and paste this into movies.xml file. What I would like is for the XSLT to copy the entire XML file, but reorder the item lists. Note that the element I'm sorting, "item[2]/subitems/item" is fairly specific to my database setup - Films is the second top-level database item.
- Code: Select all
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="no"
encoding="UTF-8"/>
<xsl:preserve-space elements="*"/>
<xsl:template match="database">
<xsl:for-each select="item[2]/subitems/item">
<xsl:sort select="display" data-type="text"/>
<xsl:copy>
<xsl:copy-of select="*"/>
</xsl:copy>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>