1 <?xml version=
"1.0" encoding=
"utf-8" standalone=
"yes" ?>
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 <!-- ************************************************************************************** -->
21 <!-- * Transformation from New Format XCS & XCU to schema description *** -->
22 <!-- ************************************************************************************** -->
23 <xsl:transform version=
"1.0" xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
24 xmlns:
xsi=
"http://www.w3.org/1999/XMLSchema-instance"
25 xmlns:
xs=
"http://www.w3.org/2001/XMLSchema"
26 xmlns:
oor=
"http://openoffice.org/2001/registry"
27 xmlns:
install=
"http://openoffice.org/2004/installation">
29 <!-- Get the correct format -->
30 <xsl:output method=
"xml" indent=
"yes" />
32 <xsl:param name=
"xcs"/>
33 <xsl:param name=
"schemaRoot">.
</xsl:param>
35 <xsl:variable name=
"schemaRootURL">
36 <xsl:value-of select=
"$schemaRoot"/>
38 <xsl:variable name=
"schemaURL">
39 <xsl:value-of select=
"$xcs"/>
42 <!-- ************************************** -->
43 <!-- * oor:component-data *** -->
44 <!-- ************************************** -->
45 <xsl:template match=
"/oor:component-data">
46 <xsl:variable name=
"component-schema" select=
"document($schemaURL)/oor:component-schema"/>
47 <xsl:for-each select=
"node|prop">
48 <xsl:apply-templates select=
".">
49 <xsl:with-param name=
"context" select=
"$component-schema/component/*[@oor:name = current()/@oor:name]"/>
50 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
51 </xsl:apply-templates>
55 <!-- ****************************************** -->
56 <!-- * handle template references *** -->
57 <!-- ****************************************** -->
58 <xsl:template name=
"resolve-template">
59 <xsl:param name =
"node-type"/>
60 <xsl:param name =
"schema-type"/>
61 <xsl:param name =
"component-schema"/>
62 <xsl:variable name =
"path">
63 <xsl:call-template name=
"collectPath"/>
66 <xsl:if test=
"not ($component-schema)">
67 <xsl:message terminate=
"yes">ERROR: Template '
<xsl:value-of select=
"$node-type"/>',
68 referenced from node '
<xsl:value-of select=
"$path"/>'
69 does not exist in schema!
74 <xsl:when test=
"$schema-type='node-ref'">
75 <xsl:apply-templates select=
".">
76 <xsl:with-param name=
"context" select=
"$component-schema/templates/*[@oor:name = $node-type]"/>
77 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
78 </xsl:apply-templates>
80 <xsl:when test=
"$schema-type='set'">
81 <xsl:for-each select=
"node|prop">
82 <xsl:apply-templates select=
".">
83 <xsl:with-param name=
"context" select=
"$component-schema/templates/*[@oor:name = $node-type]"/>
84 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
85 </xsl:apply-templates>
89 <xsl:message terminate=
"yes">ERROR: The schema element for node
<xsl:value-of select=
"$path"/>
90 is a
<xsl:value-of select=
"$schema-type"/> and should not have a node-type.
96 <!-- ****************************************** -->
98 <!-- ****************************************** -->
99 <xsl:template match=
"node">
100 <xsl:param name =
"context"/>
101 <xsl:param name =
"component-schema"/>
102 <xsl:variable name =
"path">
103 <xsl:call-template name=
"collectPath"/>
106 <xsl:if test=
"not ($context)">
107 <xsl:message terminate=
"yes">ERROR: Node '
<xsl:value-of select=
"$path"/>' does not exist in schema!
</xsl:message>
110 <xsl:call-template name=
"checkModule"/>
111 <xsl:call-template name=
"checkDuplicates"/>
114 <!-- look for matching templates in other components -->
115 <xsl:when test=
"$context/@oor:node-type and $context/@oor:component">
116 <xsl:variable name=
"fileURL">
117 <xsl:call-template name=
"composeFileURL">
118 <xsl:with-param name=
"componentName"><xsl:value-of select=
"$context/@oor:component"/></xsl:with-param>
122 <xsl:call-template name=
"resolve-template">
123 <xsl:with-param name=
"node-type" select=
"$context/@oor:node-type"/>
124 <xsl:with-param name=
"schema-type" select=
"local-name($context)"/>
125 <xsl:with-param name=
"component-schema" select=
"document($fileURL)/oor:component-schema"/>
128 <!-- look for matching templates within the same component -->
129 <xsl:when test=
"$context/@oor:node-type">
130 <xsl:call-template name=
"resolve-template">
131 <xsl:with-param name=
"node-type" select=
"$context/@oor:node-type"/>
132 <xsl:with-param name=
"schema-type" select=
"local-name($context)"/>
133 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
136 <!-- is the node extensible ? -->
137 <xsl:when test=
"$context/@oor:extensible='true'">
138 <xsl:for-each select=
"node|prop">
139 <xsl:apply-templates select=
"." mode=
"extensible">
140 <xsl:with-param name=
"context" select=
"$context/*[@oor:name = current()/@oor:name]"/>
141 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
142 </xsl:apply-templates>
146 <xsl:for-each select=
"node|prop">
147 <xsl:apply-templates select=
".">
148 <xsl:with-param name=
"context" select=
"$context/*[@oor:name = current()/@oor:name]"/>
149 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
150 </xsl:apply-templates>
156 <!-- ****************************************** -->
158 <!-- ****************************************** -->
159 <xsl:template match=
"prop">
160 <xsl:param name =
"context"/>
161 <xsl:variable name =
"path">
162 <xsl:call-template name=
"collectPath"/>
166 <xsl:if test=
"not ($context)">
167 <xsl:message terminate=
"yes">ERROR: Property '
<xsl:value-of select=
"$path"/>' does not exist in schema !
</xsl:message>
170 <xsl:if test=
"@oor:op">
171 <xsl:message terminate=
"yes">ERROR: Property '
<xsl:value-of select=
"$path"/>' has unexpected operation '
<xsl:value-of select=
"@oor:op"/>' !
</xsl:message>
174 <xsl:call-template name=
"checkModule"/>
175 <xsl:call-template name=
"checkDuplicates"/>
177 <xsl:apply-templates />
180 <!-- ****************************************** -->
182 <!-- ****************************************** -->
183 <xsl:template match=
"value">
184 <xsl:call-template name=
"checkModule"/>
186 <xsl:if test=
"@install:module">
187 <xsl:variable name =
"path">
188 <xsl:call-template name=
"collectPath"/>
190 <xsl:variable name =
"module" select=
"@install:module"/>
191 <xsl:variable name =
"lang" select=
"@xml:lang"/>
193 <xsl:if test=
"following-sibling::value[@install:module=$module and @xml:lang=$lang]">
194 <xsl:message terminate=
"yes">ERROR: Property '
<xsl:value-of select=
"$path"/>' has multiple values for module
<xsl:value-of select=
"$module"/> and locale
<xsl:value-of select=
"$lang"/>!
</xsl:message>
196 <xsl:if test=
"not(preceding-sibling::value/@install:module)">
197 <xsl:message>ATTENTION: Property '
<xsl:value-of select=
"$path"/>' has different values for different modules. Make sure the modules are mutually exclusive!
</xsl:message>
202 <!-- ****************************************** -->
203 <!-- * node (mode:extensible) - not supported * -->
204 <!-- ****************************************** -->
205 <xsl:template match=
"node" mode=
"extensible">
206 <xsl:variable name =
"path">
207 <xsl:call-template name=
"collectPath"/>
210 <xsl:message terminate=
"yes">ERROR: Node '
<xsl:value-of select=
"$path"/>' is within an extensible node!
</xsl:message>
212 <!-- ****************************************** -->
213 <!-- * prop (mode:extensible) *** -->
214 <!-- ****************************************** -->
215 <xsl:template match=
"prop" mode=
"extensible">
216 <xsl:param name =
"context"/>
217 <xsl:variable name =
"path">
218 <xsl:call-template name=
"collectPath"/>
222 <xsl:when test=
"not(@oor:op)">
223 <xsl:if test=
"not ($context)">
224 <xsl:message terminate=
"yes">ERROR: Property '
<xsl:value-of select=
"$path"/>' does not exist in schema!
</xsl:message>
227 <xsl:when test=
"@oor:op='replace'">
228 <xsl:if test=
"not (@oor:type)">
229 <xsl:message terminate=
"yes">ERROR: Property '
<xsl:value-of select=
"$path"/>' does not have a type!
</xsl:message>
233 <xsl:message terminate=
"yes">ERROR: Property '
<xsl:value-of select=
"$path"/>' has unexpected operation '
<xsl:value-of select=
"@oor:op"/>'!
</xsl:message>
237 <xsl:call-template name=
"checkModule"/>
238 <xsl:call-template name=
"checkDuplicates"/>
242 <!-- ************************************* -->
243 <!-- * checkDuplicates *** -->
244 <!-- ************************************* -->
245 <xsl:template name=
"checkDuplicates">
246 <xsl:variable name=
"item-name" select=
"@oor:name"/>
247 <xsl:if test=
"following-sibling::*[@oor:name = $item-name]">
248 <xsl:variable name =
"path">
249 <xsl:call-template name=
"collectPath"/>
251 <xsl:message terminate=
"yes">ERROR: Duplicate node/prop '
<xsl:value-of select=
"$path"/>'!
</xsl:message>
256 <!-- ************************************* -->
257 <!-- * checkModule *** -->
258 <!-- ************************************* -->
259 <xsl:template name=
"checkModule">
260 <xsl:if test=
"@install:module">
261 <xsl:if test=
"ancestor::*[@install:module]">
262 <xsl:message terminate=
"yes">ERROR: Nested modules are not supported. Found module '
<xsl:value-of select=
"@install:module"/>' within module '
<xsl:value-of select=
"ancestor::*/@install:module"/>'!
268 <!-- ************************************* -->
269 <!-- * collectPath *** -->
270 <!-- ************************************* -->
271 <xsl:template name=
"collectPath">
272 <xsl:for-each select=
"ancestor-or-self::node()[@oor:name]">
273 <xsl:text>/
</xsl:text><xsl:value-of select=
"@oor:name"/>
278 <!-- ****************************** -->
279 <!-- * composeFileURL *** -->
280 <!-- ****************************** -->
281 <xsl:template name=
"composeFileURL">
282 <xsl:param name=
"componentName"/>
283 <xsl:variable name=
"fileURL">
284 <xsl:value-of select=
"$schemaRootURL"/>/
<xsl:value-of select=
"translate($componentName,'.','/')"/><xsl:text>.xcs
</xsl:text>
286 <xsl:value-of select=
"$fileURL"/>