<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--    This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 3 of the License, or
        (at your option) any later version.
        
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
        
        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
        MA 02110-1301, USA. -->
<!--	This style-sheet "improve-latin-dictionary.xsl" is licensed under the GPLv3.
	    Read the full license text: http://script.blau.in/etc/GPL_License -->
<!--    201004 latin -->


<xsl:template match="lexicon"><xsl:text>
</xsl:text><!-- 201004 --><xsl:comment>    Ralf's Latin dictionary - German pronunciation (version 0.1.2; April 10, 2010)
        The size of this dictionary has been reduced. 
        You can import this dictionary into 'simon'.</xsl:comment><xsl:text>
</xsl:text>
<xsl:comment>    This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 3 of the License, or
        (at your option) any later version.
        
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
        
        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
        MA 02110-1301, USA. </xsl:comment><xsl:text>
</xsl:text>
<lexicon version="1.0" alphabet="ipa" xml:lang="la-DE">

<xsl:for-each-group select="lexeme" group-by="grapheme">
 <xsl:sort select="grapheme" order="ascending"/>
 <xsl:call-template name="create-latin-lexeme-element"/>
</xsl:for-each-group><xsl:text>
</xsl:text>
</lexicon>
</xsl:template>

<xsl:template name="create-latin-lexeme-element">
 <xsl:variable name="current-latin-lexeme">  
 <xsl:choose>
   <xsl:when test="ends-with(grapheme, 'que')"/>
   <xsl:when test="ends-with(grapheme, 've')"/>
   <xsl:when test="ends-with(grapheme, 'ne')"/>
   <xsl:otherwise>
 <xsl:text>
 </xsl:text>
 <xsl:element name="lexeme">
  <xsl:call-template name="create-latin-role-attribute"/>
  <xsl:call-template name="create-latin-grapheme-element"/>
  <xsl:call-template name="create-latin-phoneme-element"/><xsl:text>
 </xsl:text>
 </xsl:element>
 </xsl:otherwise>
 </xsl:choose>
 </xsl:variable>
 <xsl:sequence select="$current-latin-lexeme"/>
</xsl:template>

<xsl:template name="create-latin-role-attribute">
 <xsl:attribute name="role" select="@role"/>
</xsl:template>

<xsl:template name="create-latin-grapheme-element">
 <xsl:variable name="current-grapheme"><xsl:text>
  </xsl:text>
  <xsl:element name="grapheme">
   <xsl:value-of select="grapheme"/>
  </xsl:element>
 </xsl:variable>
 <xsl:sequence select="$current-grapheme"/>
</xsl:template>

<xsl:template name="create-latin-phoneme-element">
 <xsl:variable name="sierra-outside">
  <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text>
   <xsl:element name="phoneme">
    <xsl:variable name="sierra">
     <xsl:value-of select="."/>
    </xsl:variable>
     <xsl:sequence select="$sierra"/>
   </xsl:element>
  </xsl:for-each>
 </xsl:variable>
 <xsl:sequence select="$sierra-outside"/>
</xsl:template>

</xsl:stylesheet>

