<?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, see <http://www.gnu.org/licenses/>. -->
<!--Author of this style sheet: Ralf Herzog
    Date of creation: June 2010 
    License of this style-sheet: GPLv3 
    You are explicitly allowed to modify/redistribute this style-sheet. -->
    
<xsl:template match="lexicon"><xsl:text>
</xsl:text>
<xsl:comment>    Ralf's German dictionary (version 0.1.9.7; <xsl:value-of select="substring-before(string(current-date()), '+')"/>)
        with <xsl:value-of select="count(lexeme)"/> Standard German words. 
        Import this PLS dictionary into 'simon'. More info:
        http://spirit.blau.in/simon/tag/de/  </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, see &lt;http://www.gnu.org/licenses/&gt;.  </xsl:comment><xsl:text>
</xsl:text><xsl:comment>    License is GPLv3. Read the full license text: http://script.blau.in/etc/GPL_License </xsl:comment>
<xsl:text>
</xsl:text>
<xsl:text disable-output-escaping="yes">&lt;lexicon version="1.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://www.w3.org/2005/01/pronunciation-lexicon 
        http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd"
      alphabet="ipa" xml:lang="de-DE"&gt;</xsl:text><xsl:text>
</xsl:text>
<!--
-->
    

  <metadata>
    <rdf:RDF
       xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
       xmlns:dc  = "http://purl.org/dc/elements/1.1/"><xsl:text>
       </xsl:text>

     <!-- Metadata about this PLS document -->
     <rdf:Description rdf:about=""
       dc:title="Ralf's German dictionary"
       dc:description="Pronunciation of Standard German words"
       dc:publisher="Ralf Herzog"
       dc:date="2010-05-13"
       dc:rights="GPLv3"
       dc:format="application/pls+xml"><xsl:text>
</xsl:text>
       <dc:creator>Ralf Herzog</dc:creator><xsl:text>
</xsl:text>
     </rdf:Description>
    </rdf:RDF><xsl:text>
</xsl:text>
  </metadata><!--
<xsl:value-of select="unparsed-text('/home/ubuntu/testdir.txt')"/>-->
<xsl:for-each-group select="lexeme" group-by="grapheme">
 <!--<xsl:sort select="grapheme" order="ascending"/>-->
 <xsl:text>
 </xsl:text>
 
   
 <xsl:element name="lexeme">
  <xsl:attribute name="role">
   <xsl:call-template name="display-value-of-role-attribute"/>
  </xsl:attribute>
  <xsl:for-each select="grapheme">
   <xsl:call-template name="create-german-grapheme-element"/>
  </xsl:for-each>
  <xsl:for-each-group select="phoneme" group-by="distinct-values(.)">
  
   <xsl:variable name="first-phoneme-element">
    <xsl:call-template name="improve-german-phoneme-element"/> 
   </xsl:variable> 
   
   <xsl:variable name="second-phoneme-element"> 
    <xsl:call-template name="generate-additional-phoneme-element">  
     <xsl:with-param name="improved-phoneme-element">
      <xsl:sequence select="$first-phoneme-element"/>
     </xsl:with-param>  <!---->
    </xsl:call-template>
   </xsl:variable> 
   <!--
<xsl:if test="contains(unparsed-text('/home/ubuntu/testdir.txt'), $first-phoneme-element)">MUSIC</xsl:if>
   --><xsl:text>
   </xsl:text><xsl:element name="phoneme">
   <xsl:sequence select="$first-phoneme-element"/></xsl:element>
   <!-- 
   <xsl:if test="boolean(document('file:///home/ubuntu/Documents/201006/audacity/xaa-folder/ipa/.flac'))">scriptblauin</xsl:if>
    -->
   <xsl:if test="not($first-phoneme-element eq $second-phoneme-element)"><xsl:text>
   </xsl:text>  <xsl:element name="phoneme">
       <xsl:sequence select="$second-phoneme-element"/></xsl:element>
   </xsl:if>
  </xsl:for-each-group>
  <xsl:text>
 </xsl:text>
 </xsl:element>
</xsl:for-each-group><xsl:text>
</xsl:text><!--
</lexicon>--><xsl:text disable-output-escaping="yes">&lt;/lexicon&gt;</xsl:text><xsl:text>
</xsl:text>
<xsl:comment> This German PLS dictionary is licensed under the GPLv3. </xsl:comment><xsl:text>
</xsl:text>
</xsl:template>

<!-- June 2010 -->
<xsl:template name="improve-german-phoneme-element">
 <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
 <xsl:variable name="sierra">
    <xsl:variable name="sierra" select="replace($sierra, 'aʊ̯ktsɪoːn', 'aʊ̯kt͡si̯on')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'N', 'ŋ')"/> 
    <xsl:variable name="sierra" select="replace($sierra, '2', 'ø')"/>
    <xsl:variable name="sierra" select="replace($sierra, '9', 'œ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'U', 'ʊ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'R', 'ʀ')"/>
    <xsl:variable name="sierra" select="replace($sierra, '6', 'ɐ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'O', 'ɔ')"/>
    <xsl:variable name="sierra" select="replace($sierra, '@', 'ə')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'Y', 'ʏ')"/>
    <xsl:variable name="sierra" select="replace($sierra, ':', 'ː')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'I', 'ɪ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'i:', 'iː')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'S', 'ʃ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'gyltɪg', 'gʏltɪg')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'E', 'ɛ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'o:', 'oː')"/>
    <xsl:sequence select="$sierra"/>
 </xsl:variable>
 
 <xsl:variable name="sierra">
  <xsl:choose>
    <xsl:when test="contains(lower-case(../grapheme), 'verwandt')"><xsl:value-of select="replace($sierra, 'vɐvant', 'fɐvant')"/></xsl:when>

  <xsl:when test="ends-with(lower-case(../grapheme), 'elnder')
   and ends-with($sierra, 'ntɐ')"><xsl:value-of select="replace($sierra, 'ntɐ', 'əlndɐ')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'elndes')
   and ends-with($sierra, 'ntəs')"><xsl:value-of select="replace($sierra, 'ntəs', 'əlndəs')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'elnden')
   and ends-with($sierra, 'ntən')"><xsl:value-of select="replace($sierra, 'ntən', 'əlndən')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'elndem')
   and ends-with($sierra, 'ntəm')"><xsl:value-of select="replace($sierra, 'ntəm', 'əlndəm')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'elnde')
   and ends-with($sierra, 'ntə')"><xsl:value-of select="replace($sierra, 'ntə', 'əlndə')"/></xsl:when> 
  <xsl:when test="contains(lower-case(../grapheme), 'magazin')"><xsl:value-of select="replace($sierra, 'magat͡sɪn', 'magat͡siːn')"/></xsl:when>
   <xsl:when test="contains(lower-case(../grapheme), 'vermögen')"><xsl:value-of select="replace($sierra, 'vɐmøːgən', 'fɛʀmøːgən')"/></xsl:when>
   <xsl:when test="contains(lower-case(../grapheme), 'verhalten')"><xsl:value-of select="replace($sierra, 'vɐhalt', 'fɐhalt')"/></xsl:when>
   <xsl:when test="contains(lower-case(../grapheme), 'verlauf')"><xsl:value-of select="replace($sierra, 'vɐlaʊ̯f', 'fɐlaʊ̯f')"/></xsl:when>
   <xsl:when test="contains(lower-case(../grapheme), 'strom')"><xsl:value-of select="replace($sierra, 'stʀoːm', 'ʃtʀoːm')"/></xsl:when>
   <xsl:when test="contains(lower-case(../grapheme), 'staat')"><xsl:value-of select="replace($sierra, 'staːt', 'ʃtaːt')"/></xsl:when>
   <xsl:otherwise><xsl:sequence select="$sierra"/></xsl:otherwise>
  </xsl:choose>
 </xsl:variable>

 <xsl:sequence select="$sierra"/>

</xsl:template>

<!-- June 2010 -->
<xsl:template name="display-value-of-role-attribute">
 <xsl:variable name="terminal">
  <xsl:value-of select="@role"/>
 </xsl:variable>
 <xsl:variable name="terminal">
 <xsl:choose>
  <xsl:when test="$terminal=''">
  <xsl:if test="ends-with(grapheme, 'ender')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
     <xsl:if test="ends-with(grapheme, 'ende')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
        <xsl:if test="ends-with(grapheme, 'end')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
           <xsl:if test="ends-with(grapheme, 'ernd')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
           <xsl:if test="ends-with(grapheme, 'ernde')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
           <xsl:if test="ends-with(grapheme, 'erndes')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
           <xsl:if test="ends-with(grapheme, 'erndem')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
           <xsl:if test="ends-with(grapheme, 'ernden')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
           <xsl:if test="ends-with(grapheme, 'tem')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
           <xsl:if test="ends-with(grapheme, 'ter')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
           <xsl:if test="ends-with(grapheme, 'tes')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
              <xsl:if test="ends-with(grapheme, 'ert')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
              <xsl:if test="ends-with(grapheme, 'bares')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
              <xsl:if test="ends-with(grapheme, 'barem')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
              <xsl:if test="ends-with(grapheme, 'bar')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
              <xsl:if test="ends-with(grapheme, 'bare')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if>
           
    <xsl:if test="ends-with(grapheme, 'st')">
    <xsl:text>Verb</xsl:text>
   </xsl:if>
       <xsl:if test="ends-with(grapheme, 'te')">
    <xsl:text>Verb</xsl:text>
   </xsl:if>
       <xsl:if test="ends-with(grapheme, 'tet')">
    <xsl:text>Verb</xsl:text>
   </xsl:if>
       <xsl:if test="ends-with(grapheme, 'en')">
    <xsl:text>Verb</xsl:text>
   </xsl:if>
          <xsl:if test="ends-with(grapheme, 'ern')">
    <xsl:text>Verb</xsl:text>
   </xsl:if>
     <xsl:if test="ends-with(grapheme, 'gehst')">
    <xsl:text>Verb Singular Gegenwart Indikativ</xsl:text>
   </xsl:if><!--
   <xsl:if test="ends-with(grapheme, 'endem')">
    <xsl:text>Adjektiv Dativ Singular</xsl:text>
   </xsl:if>
   <xsl:if test="ends-with(grapheme, 'enden')">
    <xsl:text>Adjektiv Akkusativ</xsl:text>
   </xsl:if>
   <xsl:if test="ends-with(grapheme, 'endes')">
    <xsl:text>Adjektiv Neutrum</xsl:text>
   </xsl:if>
   <xsl:if test="ends-with(grapheme, 'test')">
    <xsl:text>Verb Singular Imperfekt KonjunktivII</xsl:text>
   </xsl:if>
    <xsl:if test="ends-with(grapheme, 'endes')">
    <xsl:text>Adjektiv Neutrum</xsl:text>
   </xsl:if>-->
   
  </xsl:when>
  <xsl:when test="$terminal='vi'"><xsl:text>Verb Infinitiv</xsl:text></xsl:when>
  <xsl:when test="$terminal='v'"><xsl:text>Verb</xsl:text></xsl:when>
  <xsl:when test="$terminal='a'"><xsl:text>Adjektiv</xsl:text></xsl:when>
  <xsl:when test="$terminal='z'"><xsl:text>Zahlwort</xsl:text></xsl:when>
  <xsl:when test="$terminal='vs'"><xsl:text>Verb Singular</xsl:text></xsl:when>
  <xsl:when test="$terminal='vp'"><xsl:text>Verb Plural</xsl:text></xsl:when>
  <xsl:otherwise><xsl:value-of select="@role"/></xsl:otherwise>
 </xsl:choose>
 </xsl:variable>
 <xsl:sequence select="$terminal"/><!---->
</xsl:template>

<!--  -->

 <!-- June 2010 -->
<xsl:template name="generate-additional-phoneme-element">
 <xsl:param name="improved-phoneme-element"></xsl:param><!---->

  <xsl:variable name="sierra"><xsl:sequence select="$improved-phoneme-element"/></xsl:variable>
  <xsl:variable name="sierra">
   <xsl:choose><!--
   <xsl:when test="contains(lower-case(../grapheme), 'verhalten')"><xsl:value-of select="replace($sierra, 'vɐhalt', 'fɐhalt')"/></xsl:when> 
   <xsl:when test="contains(lower-case(../grapheme), 'verhalten')"><xsl:value-of select="replace($sierra, 'vɐhalt', 'fɐhalt')"/></xsl:when> 
   <xsl:when test="contains(lower-case(../grapheme), 'verhalten')"><xsl:value-of select="replace($sierra, 'vɐhalt', 'fɐhalt')"/></xsl:when> 
   <xsl:when test="contains(lower-case(../grapheme), 'verhalten')"><xsl:value-of select="replace($sierra, 'vɐhalt', 'fɐhalt')"/></xsl:when> -->
   
   <xsl:when test="ends-with(lower-case(../grapheme), 'ar')"><xsl:value-of select="replace($sierra, 'aːʀ', 'aːɐ̯')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'ars')"><xsl:value-of select="replace($sierra, 'aːʀs', 'aːɐ̯s')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'aren')"><xsl:value-of select="replace($sierra, 'aːʀən', 'aːɐ̯n')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'ierendes')"><xsl:value-of select="replace($sierra, 'iːʀəndəs', 'iːɐ̯ndəs')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'ierender')"><xsl:value-of select="replace($sierra, 'iːʀəndɐ', 'iːɐ̯ndɐ')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'ierendem')"><xsl:value-of select="replace($sierra, 'iːʀəndəm', 'iːɐ̯ndəm')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'ierende')"><xsl:value-of select="replace($sierra, 'iːʀəndə', 'iːɐ̯ndə')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'uren')
   and not(ends-with(../grapheme, 'äuren'))"><xsl:value-of select="replace($sierra, 'uːʀən', 'uːɐ̯n')"/></xsl:when>  
   <xsl:when test="ends-with(lower-case(../grapheme), 'üren')"><xsl:value-of select="replace($sierra, 'yːʀən', 'yːɐ̯n')"/></xsl:when>
   <xsl:when test="ends-with(../grapheme, 'ür')"><xsl:value-of select="replace($sierra, 'yːʀ', 'yːɐ̯')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'schen')"><xsl:value-of select="replace($sierra, 'ʃən', 'ʃn̩')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'ur')
   and not(ends-with(../grapheme, 'eur'))"><xsl:value-of select="replace($sierra, 'uːʀ', 'uːɐ̯')"/></xsl:when> 
                  
   <xsl:when test="ends-with(lower-case(../grapheme), 'ben')"><xsl:value-of select="replace($sierra, 'bən', 'bm̩')"/></xsl:when>
   <xsl:when test="ends-with(../grapheme, 'bens')"><xsl:value-of select="replace($sierra, 'bəns', 'bm̩s')"/></xsl:when>
   <xsl:when test="ends-with(../grapheme, 'gens') and
   not(ends-with(../grapheme, 'ngens'))"><xsl:value-of select="replace($sierra, 'gəns', 'gŋ̩s')"/></xsl:when>
   
   <xsl:when test="ends-with(../grapheme, 'gen') and
   not(ends-with(../grapheme, 'ngen'))"><xsl:value-of select="replace($sierra, 'gən', 'gŋ̩')"/></xsl:when>
   <xsl:when test="ends-with(lower-case(../grapheme), 'ier') and
   ends-with(., 'iːʀ') and
   not(ends-with(../grapheme, 'eier'))"><xsl:value-of select="replace($sierra, 'iːʀ', 'iːɐ̯')"/></xsl:when>
   <xsl:when test="ends-with(lower-case(../grapheme), 'ierens')"><xsl:value-of select="replace($sierra, 'iːʀəns', 'iːɐ̯n̩s')"/></xsl:when>
   <xsl:when test="contains(lower-case(../grapheme), 'augenblick') or 
   contains(lower-case(../grapheme), 'augenbraue') or
   starts-with((../grapheme), 'Augen')"><xsl:value-of select="replace($sierra, 'aʊ̯gən', 'aʊ̯gŋ̩')"/></xsl:when>
   <xsl:otherwise><xsl:sequence select="$sierra"/></xsl:otherwise>
   </xsl:choose>
  </xsl:variable>

   <xsl:sequence select="$sierra"/>

</xsl:template>

<!-- May 2010 not used any more -->
<xsl:template name="when-grapheme-contains-then-modify-phoneme">
  <xsl:choose>       
   <!-- June 2010 -->
  <xsl:when test="contains(lower-case(grapheme), 'staat')"> 
    <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
    <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
    <xsl:variable name="sierra" select="replace($sierra, 'staːt', 'ʃtaːt')"/>
    <xsl:sequence select="$sierra"/></phoneme>
    </xsl:for-each>
  </xsl:when> 
     <!-- June 2010 -->
  <xsl:when test="contains(lower-case(grapheme), 'stift')"> 
    <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
    <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
    <xsl:variable name="sierra" select="replace($sierra, 'stɪft', 'ʃtɪft')"/>
    <xsl:sequence select="$sierra"/></phoneme>
    </xsl:for-each>
  </xsl:when> 
   <!-- June 2010 -->
  <xsl:when test="contains(lower-case(grapheme), 'show')"> 
    <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
    <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
    <xsl:variable name="sierra" select="replace($sierra, 'shoːv', 'ʃoʊ̯')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'ʃɔv', 'ʃoʊ̯')"/>
    <xsl:sequence select="$sierra"/></phoneme>
    </xsl:for-each>
  </xsl:when>  
     <!-- June 2010 
  <xsl:when test="contains(lower-case(grapheme), 'ts')"> 
    <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
    <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
    <xsl:variable name="sierra" select="replace($sierra, 'ts', 't͡s')"/>
    <xsl:sequence select="$sierra"/></phoneme>
    </xsl:for-each>
  </xsl:when>      -->
   <!-- June 2010 -->
  <xsl:when test="contains(lower-case(grapheme), 'z')"> 
    <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
    <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
    <xsl:variable name="sierra" select="replace($sierra, 'ts', 't͡s')"/>
    <xsl:sequence select="$sierra"/></phoneme>
    </xsl:for-each>
  </xsl:when> 
        <!-- June 2010 
  <xsl:when test="contains(lower-case(grapheme), 'stunde')"> 
    <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
    <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
    <xsl:variable name="sierra" select="replace($sierra, 'stʊnd', 'ʃtʊnd')"/>
    <xsl:sequence select="$sierra"/></phoneme>
    </xsl:for-each>
  </xsl:when> -->
      <!-- June 2010 -->
  <xsl:when test="contains(lower-case(grapheme), 'äu')"> 
    <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
    <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
    <xsl:variable name="sierra" select="replace($sierra, 'ɔʏ', 'ɔɪ̯')"/>
    <xsl:sequence select="$sierra"/></phoneme>
    </xsl:for-each>
  </xsl:when> 
    <!-- June 2010 -->
  <xsl:when test="contains(lower-case(grapheme), 'eu')"> 
    <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
    <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
    <xsl:variable name="sierra" select="replace($sierra, 'ɔʏ', 'ɔɪ̯')"/>
    <xsl:sequence select="$sierra"/></phoneme>
    </xsl:for-each>
  </xsl:when> 
  <!-- June 2010 
  <xsl:when test="contains(lower-case(grapheme), 'verbände')"> 
    <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
    <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
    <xsl:variable name="sierra" select="replace($sierra, 'vɐbɛnd', 'fɐbɛnd')"/>
    <xsl:sequence select="$sierra"/></phoneme>
    </xsl:for-each>
  </xsl:when> -->
      <!-- June 2010 
  <xsl:when test="contains(lower-case(grapheme), 'öl')"> 
    <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
    <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
    <xsl:variable name="sierra" select="replace($sierra, 'ʔœl', 'ʔøːl')"/>
    <xsl:sequence select="$sierra"/></phoneme>
    </xsl:for-each>
  </xsl:when> -->
    <!-- June 2010 
  <xsl:when test="contains(lower-case(grapheme), 'streit')"> 
    <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
    <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
    <xsl:variable name="sierra" select="replace($sierra, 'stʀaɪ̯t', 'ʃtʀaɪ̯t')"/>
    <xsl:sequence select="$sierra"/></phoneme>
    </xsl:for-each>
  </xsl:when> -->
  <!-- May 2010 
  <xsl:when test="contains(lower-case(grapheme), 'quer')"> 
    <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
    <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
    <xsl:variable name="sierra" select="replace($sierra, 'kvɛʀ', 'kveːʀ')"/>
    <xsl:sequence select="$sierra"/></phoneme>
    </xsl:for-each>
  </xsl:when> -->


  <!-- May 2010 
  <xsl:when test="ends-with(grapheme, 'ohr')">
    <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
    <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
    <xsl:variable name="sierra" select="replace($sierra, 'oːʀ', 'oːɐ̯')"/>
    <xsl:sequence select="$sierra"/></phoneme>
    </xsl:for-each>
  </xsl:when>-->

  <xsl:otherwise>
  <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><phoneme>
   <xsl:variable name="sierra"><xsl:value-of select="."/></xsl:variable>
   <xsl:sequence select="$sierra"/></phoneme>
   </xsl:for-each><!--
    <xsl:call-template name="improve-quality-of-phonemes"/> -->
  </xsl:otherwise>
  </xsl:choose>

</xsl:template>

<!-- June 2010 not used any more -->
<xsl:template name="improve-quality-of-phonemes">
 <xsl:variable name="sierra">
  <xsl:for-each select="phoneme"><xsl:text>
   </xsl:text><!--<xsl:value-of select="generate-id(.)"/>_<xsl:number value="position()" format="000001" />-->
   <xsl:element name="phoneme">
    <xsl:variable name="sierra">
     <xsl:value-of select="."/>
    </xsl:variable>
    <!-- May 2010 <xsl:variable name="sierra" select="replace($sierra, '', '')"/>
    <xsl:variable name="sierra" select="replace($sierra, '', '')"/>
   <xsl:variable name="sierra" select="replace($sierra, '', '')"/>-->

    <xsl:variable name="sierra" select="replace($sierra, 'œstɛʀʀaɪ̯ç', 'øːstɐʀaɪ̯ç')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'kɔmuːnal', 'kɔmunaːl')"/>
    <xsl:variable name="sierra" select="replace($sierra, 't͡suːʀyk', 't͡suːʀʏk')"/>
    <xsl:variable name="sierra" select="replace($sierra, 't͡suːɔʀdn', 't͡suːʔɔʀdn')"/>
<xsl:variable name="sierra" select="replace($sierra, 'veːʀɛndəʀʊŋ', 'fɛʀɛndəʀʊŋ')"/>
<xsl:variable name="sierra" select="replace($sierra, 'ʃʊldf', 'ʃʊltf')"/>
<xsl:variable name="sierra" select="replace($sierra, 'kʀiːgsç', 'kʀiːgsʃ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'vɐgaːbə', 'fɐgaːbə')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'vɐkaʊ̯f', 'fɐkaʊ̯f')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'vɐkeːʀ', 'fɐkeːʀ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'vɐtsiːɐ̯t', 'fɐt͡siːɐ̯t')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'veːʀanstaltʊŋ', 'fɛʀanʃtaltʊŋ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'hœltsɐ', 'hœlt͡sɐ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'vɐtaɪ̯lʊŋ', 'fɐtaɪ̯lʊŋ')"/>
    <xsl:sequence select="$sierra"/>
   </xsl:element>
  </xsl:for-each>
 </xsl:variable>
 <xsl:sequence select="$sierra"/>
</xsl:template>

<!-- May 2010 -->
<xsl:template name="create-german-grapheme-element">
 <xsl:variable name="current-grapheme">
 <xsl:text>
  </xsl:text>
  <xsl:element name="grapheme">
   <xsl:value-of select="."/>
  </xsl:element>
 </xsl:variable>
 <xsl:sequence select="$current-grapheme"/>
</xsl:template>

</xsl:stylesheet>
<!--	This style-sheet is licensed under the GPLv3.
	    Read the full license text: http://script.blau.in/etc/GPL_License -->

