Sample XML:
<term>
<name>facies</name>
<translation language="en">facies</translation>
<definition><num>1.</num> cara <num>2.</num> superficie externa, superficie anterior</definition>
</term>
<term>
<name>factores angiógenos</name>
<translation language="en">angiogenic factors</translation>
<definition>descripción de sustancias que favorecen el desarrollo o la formación nueva de vasos sanguíneos</definition>
</term>
<term>
<name>factores de la coagulación</name>
<translation language="en">coagulation factors</translation>
<definition>la cascada de la coagulación de la sangre consta de 12 factores en total, todos ellos necesarios para que funcione bien</definition>
</term>
I have an XSLT file which makes a list of names mapped to name, and a translation if one exists.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="terms">
var allwords = [
<xsl:for-each select="letter">
<xsl:for-each select="term">
<xsl:call-template name="term"></xsl:call-template>
</xsl:for-each>
</xsl:for-each>
['','']
];
</xsl:template>
<xsl:template name="term">
['<xsl:value-of select="name"/>', '<xsl:value-of select="name"/>'],
<xsl:if test="name!=translation">
['<xsl:value-of select="translation"/>', '<xsl:value-of select="name"/>'],
</xsl:if>
</xsl:template>
</xsl:stylesheet>
This works out great, producing the following
var allwords =
[ ['facies', 'facies'],
['factores angiógenos', 'factores angiógenos'],
['angiogenic factors', factores angiógeno],
['factores de la coagulació', 'factores de la coagulació']
etc...
However, as you can see the first part in the array is not in alphabetical order any more, because of the addition of the english word.
It needs to be in alphabetical order, so in this case "angiogenic factors" would be the first element in the array
Any ideas?