Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / tools / addlang.xsl @ 187

History | View | Annotate | Download (1.5 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3

    
4
   <xsl:output encoding="utf-8" method="xml" indent="yes"/>
5

    
6
   <xsl:param name="newfile"/>
7
   <xsl:param name="newlang"/>
8
   <xsl:param name="overwrite">true</xsl:param>
9

    
10
   <xsl:key name="K" match="entry" use="key"/>
11

    
12
   <xsl:template match="@*|processing-instruction()|comment()|text()">
13
      <xsl:copy/>
14
   </xsl:template>
15

    
16
   <xsl:template match="text">
17
      <xsl:choose>
18
         <xsl:when test="not(@xml:lang) or not(@xml:lang=$newlang)">
19
            <xsl:copy-of select="."/>
20
         </xsl:when>
21
         <xsl:when test="$overwrite='false' and @xml:lang=$newlang">
22
            <xsl:copy-of select="."/>
23
         </xsl:when>
24
      </xsl:choose>
25

    
26
   </xsl:template>
27

    
28
   <xsl:template match="*">
29
      <xsl:copy>
30
         <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
31
      </xsl:copy>
32
   </xsl:template>
33

    
34
   <xsl:template match="entry">
35
      <xsl:variable name="k" select="key"/>
36
      <xsl:copy>
37
         <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
38
         <xsl:for-each select="document($newfile)/i18n">
39
            <xsl:for-each select="key('K',$k)">
40
               <xsl:message>Go <xsl:value-of select="$k"/>
41
               </xsl:message>
42
	              <xsl:copy-of select="text[@xml:lang=$newlang]"/>
43
            </xsl:for-each>
44
         </xsl:for-each>
45
      </xsl:copy>
46

    
47
   </xsl:template>
48
</xsl:stylesheet>