File: principal.xsl

package info (click to toggle)
apertium-br-fr 0.5.0~r61325-3
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 14,364 kB
  • sloc: xml: 275; sh: 148; makefile: 103
file content (178 lines) | stat: -rw-r--r-- 5,413 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" encoding="UTF-8"/>

<xsl:template match="/">
  <xsl:value-of select="string('&#xa;')"/> <!-- \n -->
  <xsl:apply-templates select="dictionary"/> 
</xsl:template>

<xsl:template match="dictionary">
  <dictionary><xsl:value-of select="string('&#xa;')"/><!-- \n -->
  <xsl:apply-templates select="alphabet"/>
  <xsl:apply-templates select="sdefs"/>
  <xsl:apply-templates select="pardefs"/>
  <xsl:apply-templates select="section"/>
  </dictionary><xsl:value-of select="string('&#xa;')"/><!-- \n -->
</xsl:template>

<xsl:template name="alpha" match="alphabet">
  <alphabet>  
  <xsl:apply-templates />
  </alphabet><xsl:value-of select="string('&#xa;')"/> <!-- \n -->
</xsl:template>

<xsl:template match="sdefs">
  <sdefs>
  <xsl:apply-templates />
  </sdefs>
</xsl:template>

<xsl:template match="sdef">
  <xsl:copy-of select="."/>
</xsl:template>
<!-- Since here, a copy from the dictionary -->




<!-- Generates the new paradigms from pardef -->
<xsl:template match="pardefs">
  <xsl:value-of select="string('&#xa;')"/><!-- \n -->
  <pardefs><xsl:value-of select="string('&#xa;')"/><!-- \n -->

  <!-- Copy the dictionary original paradigms -->
  <xsl:apply-templates />
  <xsl:value-of select="string('&#xa;')"/><!-- \n -->


     <!-- Generates the news paradigms -->

      <!-- in variable mypardef we save the pardefs nodes of the dictionary-->
      <xsl:variable name="mypardefs" select="//pardefs"/>

      <xsl:for-each select="$paradigms">
      <!-- Here the body of each new paradigm -->
      <pardef n='{ concat(@name,"__",@prm) }'> <xsl:value-of select="string('&#xa;')"/><!-- \n -->

	 <!-- In the variable $paradigmname we save the name of the basic paradigm for expansion -->
         <xsl:variable name="paradigmname" select="./@name"/>
	 <!-- and in the variable $paradigmprm we save the name of the variable part for expansion -->
         <xsl:variable name="paradigmprm" select="./@prm"/>

         <xsl:call-template name="pardef-generated" select="$mypardefs/pardef[./@n=$paradigmname]">
	     <xsl:with-param name="parametro" select="$paradigmprm"/>
	     <xsl:with-param name="ambito" select="$mypardefs/pardef[./@n=$paradigmname]"/>
	 </xsl:call-template> 

      </pardef>
      <xsl:value-of select="string('&#xa;')"/><!-- \n -->
    </xsl:for-each> 

  </pardefs><!--<xsl:value-of select="string('&#xa;')"/>--><!-- \n -->
</xsl:template>





<!--
<xsl:template match="pardef">
    <xsl:copy-of select="."/>
</xsl:template>
-->
<xsl:template match="pardef">
    <pardef n='{@n}'> <xsl:value-of select="string('&#xa;')"/><!-- \n -->
    <xsl:apply-templates/>
    </pardef>
    <xsl:value-of select="string('&#xa;')"/><!-- \n -->
</xsl:template>

<xsl:template name='pardef-generated'>
   <xsl:param name="parametro"/>
   <xsl:param name="ambito"/>
   <xsl:apply-templates select="$ambito/e">
      <xsl:with-param name="parametro" select="$parametro"/>
   </xsl:apply-templates>
   <xsl:value-of select="string('&#xa;')"/> <!-- \n -->
</xsl:template>



<!-- Copy the rest of the dictionary deleting "prm" atribute from <par> nodes-->
<xsl:template match="section">
   <xsl:copy-of select="."/>
</xsl:template>

<xsl:template match="section">
  <xsl:value-of select="string('&#xa;')"/><!-- \n -->
  <section id='{@id}' type='{@type}'>
  <xsl:apply-templates />
  </section><xsl:value-of select="string('&#xa;')"/><!-- \n -->
</xsl:template>



<xsl:template match="e[@lm]"> <!-- with 'lm' atribute-->
<xsl:param name="parametro"/>
      <xsl:value-of select="string('                        ')"/>
      <e lm='{@lm}'>
         <xsl:apply-templates>
           <xsl:with-param name="parametro" select="$parametro"/>
         </xsl:apply-templates>
      </e>   <xsl:value-of select="string('&#xa;')"/> <!-- \n -->
</xsl:template>
<xsl:template match="e[@r]">  <!-- with 'r' atribute-->
<xsl:param name="parametro"/>
      <xsl:value-of select="string('                        ')"/>
      <e r='{@r}'>
         <xsl:apply-templates>
           <xsl:with-param name="parametro" select="$parametro"/>
         </xsl:apply-templates>
      </e>   <xsl:value-of select="string('&#xa;')"/> <!-- \n -->
</xsl:template>
<xsl:template match="e[not(@*)]">
<xsl:param name="parametro"/>
      <xsl:value-of select="string('                        ')"/>
      <e>
        <xsl:apply-templates>
           <xsl:with-param name="parametro" select="$parametro"/>
        </xsl:apply-templates>
      </e>   <xsl:value-of select="string('&#xa;')"/> <!-- \n -->
</xsl:template>


<!-- If the <par> node have "prm" atribute delete it, otherwise copy -->
<xsl:template match="par[@prm]">
       <par n='{ concat(@n,"__",@prm) }' />
</xsl:template>

<xsl:template match="par[not(@prm)]">
       <xsl:copy-of select="."/>
</xsl:template>
<!-- ********************************************************** -->


<xsl:template match="i">
<xsl:param name="parametro"/>
      <i>
        <xsl:apply-templates>
           <xsl:with-param name="parametro" select="$parametro"/>
        </xsl:apply-templates>
      </i>
</xsl:template>



<xsl:template match="p|re|s|a|b|j">
   <xsl:copy-of select="."/>
</xsl:template>

<xsl:template match="prm">
   <xsl:param name="parametro"/>
   <xsl:value-of select="$parametro"/>   
</xsl:template>


</xsl:stylesheet>