1 <?xml version=
"1.0" encoding=
"utf-8" standalone=
"yes" ?>
2 <!--***********************************************************************
4 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 Copyright 2008 by Sun Microsystems, Inc.
8 OpenOffice.org - a multi-platform office productivity suite
10 $RCSfile: alllang.xsl,v $
14 This file is part of OpenOffice.org.
16 OpenOffice.org is free software: you can redistribute it and/or modify
17 it under the terms of the GNU Lesser General Public License version 3
18 only, as published by the Free Software Foundation.
20 OpenOffice.org is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU Lesser General Public License version 3 for more details
24 (a copy is included in the LICENSE file that accompanied this code).
26 You should have received a copy of the GNU Lesser General Public License
27 version 3 along with OpenOffice.org. If not, see
28 <http://www.openoffice.org/license.html>
29 for a copy of the LGPLv3 License.
31 ************************************************************************ -->
33 <xsl:transform xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform" version=
"1.0"
34 xmlns:
xsi=
"http://www.w3.org/2001/XMLSchema-instance"
35 xmlns:
xs=
"http://www.w3.org/2001/XMLSchema"
36 xmlns:
oor=
"http://openoffice.org/2001/registry"
37 xmlns:
install=
"http://openoffice.org/2004/installation"
38 exclude-result-prefixes=
"install">
40 <!-- Get the correct format -->
41 <xsl:output method=
"xml" indent=
"yes" encoding=
"UTF-8"/>
43 <!--************************** PARAMETER ******************************** -->
44 <xsl:param name=
"locale"/>
45 <xsl:param name=
"module"/>
46 <xsl:param name=
"xcs"/>
47 <xsl:param name=
"schemaRoot">.
</xsl:param>
48 <xsl:param name=
"fallback-locale">en-US
</xsl:param>
50 <xsl:variable name=
"schemaRootURL">
51 <xsl:value-of select=
"$schemaRoot"/>
53 <xsl:variable name=
"schemaURL">
54 <xsl:value-of select=
"$xcs"/>
57 <!--************************** TEMPLATES ******************************** -->
58 <!-- ensure that at least root is available -->
59 <xsl:template match=
"/oor:component-data">
62 <xsl:when test=
"string-length($locale)">
63 <xsl:apply-templates select =
"@*" mode=
"locale"/>
64 <xsl:apply-templates select =
"node|prop" mode=
"locale"/>
67 <xsl:apply-templates select =
"@*"/>
68 <xsl:for-each select=
"node|prop">
69 <xsl:variable name=
"component-schema" select=
"document($schemaURL)/oor:component-schema"/>
70 <xsl:apply-templates select=
".">
71 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
72 <xsl:with-param name=
"context" select=
"$component-schema/component/*[@oor:name = current()/@oor:name]"/>
73 <xsl:with-param name=
"find-module" select=
"$module"/>
74 </xsl:apply-templates>
81 <!-- locale dependent data -->
82 <xsl:template match=
"node|prop" mode =
"locale">
84 <xsl:when test=
"$locale=$fallback-locale">
85 <xsl:if test=
"descendant::value[@xml:lang=$locale]/../value[not (@xml:lang)]">
87 <xsl:apply-templates select =
"@*" mode=
"locale"/>
88 <xsl:apply-templates select =
"node|prop|value" mode =
"locale"/>
93 <xsl:if test=
"descendant::value[@xml:lang = $locale]">
95 <xsl:apply-templates select =
"@*" mode=
"locale"/>
96 <xsl:apply-templates select =
"node|prop|value" mode =
"locale"/>
103 <xsl:template match=
"value" mode=
"locale">
104 <xsl:if test=
"@xml:lang=$locale and not(@install:module)">
106 <xsl:apply-templates select =
"@*" mode=
"locale"/>
107 <xsl:value-of select=
"."/>
112 <xsl:template match =
"@*" mode=
"locale">
116 <!-- suppress all merge instructions -->
117 <xsl:template match =
"@oor:op" mode=
"locale"/>
119 <!-- suppress all module markers -->
120 <xsl:template match =
"@install:module" mode=
"locale"/>
122 <!-- locale independent data -->
124 <!-- handle template references -->
125 <xsl:template name=
"copy-resolve-template">
126 <xsl:param name =
"node-type"/>
127 <xsl:param name =
"schema-type"/>
128 <xsl:param name =
"component-schema"/>
131 <xsl:when test=
"$schema-type='node-ref'">
132 <xsl:apply-templates select=
".">
133 <xsl:with-param name=
"context" select=
"$component-schema/templates/*[@oor:name = $node-type]"/>
134 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
135 </xsl:apply-templates>
137 <xsl:when test=
"$schema-type='set'">
139 <xsl:apply-templates select =
"@*" />
140 <xsl:for-each select=
"node|prop">
141 <xsl:apply-templates select=
".">
142 <xsl:with-param name=
"context" select=
"$component-schema/templates/*[@oor:name = $node-type]"/>
143 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
144 </xsl:apply-templates>
149 <xsl:message terminate=
"yes">ERROR: The schema element for a
<xsl:value-of select=
"$schema-type"/>
150 should not have a node-type.
156 <xsl:template name=
"copy-node">
157 <xsl:param name =
"context"/>
158 <xsl:param name =
"component-schema"/>
161 <!-- look for matching templates in other components -->
162 <xsl:when test=
"$context/@oor:node-type and $context/@oor:component">
163 <xsl:variable name=
"fileURL">
164 <xsl:call-template name=
"composeFileURL">
165 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
166 <xsl:with-param name=
"componentName"><xsl:value-of select=
"$context/@oor:component"/></xsl:with-param>
169 <xsl:call-template name=
"copy-resolve-template">
170 <xsl:with-param name=
"node-type" select=
"$context/@oor:node-type"/>
171 <xsl:with-param name=
"schema-type" select=
"local-name($context)"/>
172 <xsl:with-param name=
"component-schema" select=
"document($fileURL)/oor:component-schema"/>
175 <!-- look for matching templates within the same component -->
176 <xsl:when test=
"$context/@oor:node-type">
177 <xsl:call-template name=
"copy-resolve-template">
178 <xsl:with-param name=
"node-type" select=
"$context/@oor:node-type"/>
179 <xsl:with-param name=
"schema-type" select=
"local-name($context)"/>
180 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
185 <xsl:apply-templates select =
"@*" />
186 <xsl:for-each select=
"node|prop">
187 <xsl:apply-templates select=
".">
188 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
189 <xsl:with-param name=
"context" select=
"$context/*[@oor:name = current()/@oor:name]"/>
190 </xsl:apply-templates>
197 <xsl:template match=
"node">
198 <xsl:param name =
"context"/>
199 <xsl:param name =
"component-schema"/>
201 <xsl:variable name=
"applicable-values" select=
"descendant::value[not (@xml:lang) or (@xml:lang=$fallback-locale) or (@install:module=$module)]"/>
202 <xsl:variable name=
"substantive-nodes" select=
"descendant-or-self::*[(@oor:finalized='true') or (@oor:mandatory='true') or (@oor:op!='modify')]"/>
205 <!-- go ahead, if we are in the active module -->
206 <xsl:when test=
"ancestor-or-self::*/@install:module=$module">
207 <xsl:if test=
"$applicable-values | $substantive-nodes">
208 <xsl:call-template name=
"copy-node">
209 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
210 <xsl:with-param name=
"context" select=
"$context"/>
214 <!-- strip data from wrong module -->
215 <xsl:when test=
"ancestor-or-self::*/@install:module"/>
216 <!-- looking for module -->
217 <xsl:when test=
"$module">
218 <xsl:if test=
"($applicable-values | $substantive-nodes)/ancestor-or-self::*/@install:module=$module">
219 <xsl:call-template name=
"copy-node">
220 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
221 <xsl:with-param name=
"context" select=
"$context"/>
225 <!-- copying non-module data -->
227 <xsl:if test=
"($applicable-values | $substantive-nodes)[not(ancestor-or-self::*/@install:module)]">
228 <xsl:call-template name=
"copy-node">
229 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
230 <xsl:with-param name=
"context" select=
"$context"/>
237 <xsl:template match=
"prop">
238 <xsl:param name =
"context"/>
240 <xsl:when test=
"$module and not((ancestor-or-self::* | child::value)/@install:module=$module)"/>
241 <xsl:when test=
"not($module) and ancestor-or-self::*/@install:module"/>
242 <xsl:when test=
"not ($context) or @oor:finalized='true' or @oor:op!='modify'">
244 <xsl:apply-templates select =
"@*"/>
245 <xsl:apply-templates select =
"value"/>
248 <xsl:when test=
"value[not (@xml:lang) or @install:module]">
249 <xsl:if test=
"value[not(@install:module) or @install:module=$module]">
250 <!-- copy locale independent values only, if the values differ -->
251 <xsl:variable name=
"isRedundant">
252 <xsl:call-template name=
"isRedundant">
253 <xsl:with-param name=
"schemaval" select=
"$context/value"/>
254 <xsl:with-param name=
"dataval" select=
"value[(not(@xml:lang) or @install:module) and (not(@install:module) or @install:module=$module)]"/>
257 <xsl:if test=
"$isRedundant ='false'">
259 <xsl:apply-templates select =
"@*"/>
260 <xsl:apply-templates select =
"value"/>
267 <xsl:apply-templates select =
"@*"/>
268 <xsl:apply-templates select =
"value" mode=
"fallback-locale"/>
274 <xsl:template match=
"value">
276 <xsl:when test=
"@xml:lang and not(@install:module)"/>
277 <xsl:when test=
"$module and not(ancestor-or-self::*/@install:module=$module)"/>
278 <xsl:when test=
"not($module) and ancestor-or-self::*/@install:module"/>
281 <xsl:apply-templates select =
"@*"/>
282 <xsl:value-of select=
"."/>
288 <xsl:template match=
"value" mode=
"fallback-locale">
289 <xsl:if test=
"@xml:lang=$fallback-locale and not(@install:module)">
291 <xsl:apply-templates select =
"@*"/>
292 <xsl:value-of select=
"."/>
297 <xsl:template match =
"@*">
301 <!-- suppress all merge instructions, that are out-of-module -->
302 <xsl:template match =
"@oor:op">
303 <xsl:if test=
"not($module) or ancestor::*/@install:module">
308 <!-- suppress all module markers -->
309 <xsl:template match =
"@install:module"/>
311 <!-- compares two values -->
312 <xsl:template name=
"isRedundant">
313 <xsl:param name =
"schemaval"/>
314 <xsl:param name =
"dataval"/>
316 <xsl:when test=
"not ($dataval)">
317 <xsl:value-of select=
"true()"/>
319 <xsl:when test=
"not ($schemaval)">
321 <xsl:when test=
"$dataval/@xsi:nil='true'">
322 <xsl:value-of select=
"true()"/>
325 <xsl:value-of select=
"false()"/>
329 <xsl:when test=
"$schemaval != $dataval">
330 <xsl:value-of select=
"false()"/>
333 <xsl:value-of select=
"true()"/>
338 <xsl:template name=
"composeFileURL">
339 <xsl:param name=
"componentName"/>
340 <xsl:variable name=
"fileURL">
341 <xsl:value-of select=
"$schemaRootURL"/>/
<xsl:value-of select=
"translate($componentName,'.','/')"/><xsl:text>.xcs
</xsl:text>
343 <xsl:value-of select=
"$fileURL"/>