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 2000, 2010 Oracle and/or its affiliates.
8 OpenOffice.org - a multi-platform office productivity suite
10 This file is part of OpenOffice.org.
12 OpenOffice.org is free software: you can redistribute it and/or modify
13 it under the terms of the GNU Lesser General Public License version 3
14 only, as published by the Free Software Foundation.
16 OpenOffice.org is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU Lesser General Public License version 3 for more details
20 (a copy is included in the LICENSE file that accompanied this code).
22 You should have received a copy of the GNU Lesser General Public License
23 version 3 along with OpenOffice.org. If not, see
24 <http://www.openoffice.org/license.html>
25 for a copy of the LGPLv3 License.
27 ************************************************************************ -->
29 <!-- ************************************************************************************** -->
30 <!-- * Transformation from New Format XCS & XCU to schema description *** -->
31 <!-- ************************************************************************************** -->
32 <xsl:transform version=
"1.0" xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
33 xmlns:
xsi=
"http://www.w3.org/1999/XMLSchema-instance"
34 xmlns:
xs=
"http://www.w3.org/2001/XMLSchema"
35 xmlns:
oor=
"http://openoffice.org/2001/registry"
36 xmlns:
install=
"http://openoffice.org/2004/installation">
38 <!-- Get the correct format -->
39 <xsl:output method=
"xml" indent=
"yes" />
41 <xsl:param name=
"xcs"/>
42 <xsl:param name=
"schemaRoot">.
</xsl:param>
44 <xsl:variable name=
"schemaRootURL">
45 <xsl:value-of select=
"$schemaRoot"/>
47 <xsl:variable name=
"schemaURL">
48 <xsl:value-of select=
"$xcs"/>
51 <!-- ************************************** -->
52 <!-- * oor:component-data *** -->
53 <!-- ************************************** -->
54 <xsl:template match=
"/oor:component-data">
55 <xsl:variable name=
"component-schema" select=
"document($schemaURL)/oor:component-schema"/>
56 <xsl:for-each select=
"node|prop">
57 <xsl:apply-templates select=
".">
58 <xsl:with-param name=
"context" select=
"$component-schema/component/*[@oor:name = current()/@oor:name]"/>
59 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
60 </xsl:apply-templates>
64 <!-- ****************************************** -->
65 <!-- * handle template references *** -->
66 <!-- ****************************************** -->
67 <xsl:template name=
"resolve-template">
68 <xsl:param name =
"node-type"/>
69 <xsl:param name =
"schema-type"/>
70 <xsl:param name =
"component-schema"/>
71 <xsl:variable name =
"path">
72 <xsl:call-template name=
"collectPath"/>
75 <xsl:if test=
"not ($component-schema)">
76 <xsl:message terminate=
"yes">ERROR: Template '
<xsl:value-of select=
"$node-type"/>',
77 referenced from node '
<xsl:value-of select=
"$path"/>'
78 does not exist in schema!
83 <xsl:when test=
"$schema-type='node-ref'">
84 <xsl:apply-templates select=
".">
85 <xsl:with-param name=
"context" select=
"$component-schema/templates/*[@oor:name = $node-type]"/>
86 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
87 </xsl:apply-templates>
89 <xsl:when test=
"$schema-type='set'">
90 <xsl:for-each select=
"node|prop">
91 <xsl:apply-templates select=
".">
92 <xsl:with-param name=
"context" select=
"$component-schema/templates/*[@oor:name = $node-type]"/>
93 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
94 </xsl:apply-templates>
98 <xsl:message terminate=
"yes">ERROR: The schema element for node
<xsl:value-of select=
"$path"/>
99 is a
<xsl:value-of select=
"$schema-type"/> and should not have a node-type.
105 <!-- ****************************************** -->
107 <!-- ****************************************** -->
108 <xsl:template match=
"node">
109 <xsl:param name =
"context"/>
110 <xsl:param name =
"component-schema"/>
111 <xsl:variable name =
"path">
112 <xsl:call-template name=
"collectPath"/>
115 <xsl:if test=
"not ($context)">
116 <xsl:message terminate=
"yes">ERROR: Node '
<xsl:value-of select=
"$path"/>' does not exist in schema!
</xsl:message>
119 <xsl:call-template name=
"checkModule"/>
120 <xsl:call-template name=
"checkDuplicates"/>
123 <!-- look for matching templates in other components -->
124 <xsl:when test=
"$context/@oor:node-type and $context/@oor:component">
125 <xsl:variable name=
"fileURL">
126 <xsl:call-template name=
"composeFileURL">
127 <xsl:with-param name=
"componentName"><xsl:value-of select=
"$context/@oor:component"/></xsl:with-param>
131 <xsl:call-template name=
"resolve-template">
132 <xsl:with-param name=
"node-type" select=
"$context/@oor:node-type"/>
133 <xsl:with-param name=
"schema-type" select=
"local-name($context)"/>
134 <xsl:with-param name=
"component-schema" select=
"document($fileURL)/oor:component-schema"/>
137 <!-- look for matching templates within the same component -->
138 <xsl:when test=
"$context/@oor:node-type">
139 <xsl:call-template name=
"resolve-template">
140 <xsl:with-param name=
"node-type" select=
"$context/@oor:node-type"/>
141 <xsl:with-param name=
"schema-type" select=
"local-name($context)"/>
142 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
145 <!-- is the node extensible ? -->
146 <xsl:when test=
"$context/@oor:extensible='true'">
147 <xsl:for-each select=
"node|prop">
148 <xsl:apply-templates select=
"." mode=
"extensible">
149 <xsl:with-param name=
"context" select=
"$context/*[@oor:name = current()/@oor:name]"/>
150 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
151 </xsl:apply-templates>
155 <xsl:for-each select=
"node|prop">
156 <xsl:apply-templates select=
".">
157 <xsl:with-param name=
"context" select=
"$context/*[@oor:name = current()/@oor:name]"/>
158 <xsl:with-param name=
"component-schema" select=
"$component-schema"/>
159 </xsl:apply-templates>
165 <!-- ****************************************** -->
167 <!-- ****************************************** -->
168 <xsl:template match=
"prop">
169 <xsl:param name =
"context"/>
170 <xsl:variable name =
"path">
171 <xsl:call-template name=
"collectPath"/>
175 <xsl:if test=
"not ($context)">
176 <xsl:message terminate=
"yes">ERROR: Property '
<xsl:value-of select=
"$path"/>' does not exist in schema !
</xsl:message>
179 <xsl:if test=
"@oor:op">
180 <xsl:message terminate=
"yes">ERROR: Property '
<xsl:value-of select=
"$path"/>' has unexpected operation '
<xsl:value-of select=
"@oor:op"/>' !
</xsl:message>
183 <xsl:call-template name=
"checkModule"/>
184 <xsl:call-template name=
"checkDuplicates"/>
186 <xsl:apply-templates />
189 <!-- ****************************************** -->
191 <!-- ****************************************** -->
192 <xsl:template match=
"value">
193 <xsl:call-template name=
"checkModule"/>
195 <xsl:if test=
"@install:module">
196 <xsl:variable name =
"path">
197 <xsl:call-template name=
"collectPath"/>
199 <xsl:variable name =
"module" select=
"@install:module"/>
200 <xsl:variable name =
"lang" select=
"@xml:lang"/>
202 <xsl:if test=
"following-sibling::value[@install:module=$module and @xml:lang=$lang]">
203 <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>
205 <xsl:if test=
"not(preceding-sibling::value/@install:module)">
206 <xsl:message>ATTENTION: Property '
<xsl:value-of select=
"$path"/>' has different values for different modules. Make sure the modules are mutually exclusive!
</xsl:message>
211 <!-- ****************************************** -->
212 <!-- * node (mode:extensible) - not supported * -->
213 <!-- ****************************************** -->
214 <xsl:template match=
"node" mode=
"extensible">
215 <xsl:variable name =
"path">
216 <xsl:call-template name=
"collectPath"/>
219 <xsl:message terminate=
"yes">ERROR: Node '
<xsl:value-of select=
"$path"/>' is within an extensible node!
</xsl:message>
221 <!-- ****************************************** -->
222 <!-- * prop (mode:extensible) *** -->
223 <!-- ****************************************** -->
224 <xsl:template match=
"prop" mode=
"extensible">
225 <xsl:param name =
"context"/>
226 <xsl:variable name =
"path">
227 <xsl:call-template name=
"collectPath"/>
231 <xsl:when test=
"not(@oor:op)">
232 <xsl:if test=
"not ($context)">
233 <xsl:message terminate=
"yes">ERROR: Property '
<xsl:value-of select=
"$path"/>' does not exist in schema!
</xsl:message>
236 <xsl:when test=
"@oor:op='replace'">
237 <xsl:if test=
"not (@oor:type)">
238 <xsl:message terminate=
"yes">ERROR: Property '
<xsl:value-of select=
"$path"/>' does not have a type!
</xsl:message>
242 <xsl:message terminate=
"yes">ERROR: Property '
<xsl:value-of select=
"$path"/>' has unexpected operation '
<xsl:value-of select=
"@oor:op"/>'!
</xsl:message>
246 <xsl:call-template name=
"checkModule"/>
247 <xsl:call-template name=
"checkDuplicates"/>
251 <!-- ************************************* -->
252 <!-- * checkDuplicates *** -->
253 <!-- ************************************* -->
254 <xsl:template name=
"checkDuplicates">
255 <xsl:variable name=
"item-name" select=
"@oor:name"/>
256 <xsl:if test=
"following-sibling::*[@oor:name = $item-name]">
257 <xsl:variable name =
"path">
258 <xsl:call-template name=
"collectPath"/>
260 <xsl:message terminate=
"yes">ERROR: Duplicate node/prop '
<xsl:value-of select=
"$path"/>'!
</xsl:message>
265 <!-- ************************************* -->
266 <!-- * checkModule *** -->
267 <!-- ************************************* -->
268 <xsl:template name=
"checkModule">
269 <xsl:if test=
"@install:module">
270 <xsl:if test=
"ancestor::*[@install:module]">
271 <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"/>'!
277 <!-- ************************************* -->
278 <!-- * collectPath *** -->
279 <!-- ************************************* -->
280 <xsl:template name=
"collectPath">
281 <xsl:for-each select=
"ancestor-or-self::node()[@oor:name]">
282 <xsl:text>/
</xsl:text><xsl:value-of select=
"@oor:name"/>
287 <!-- ****************************** -->
288 <!-- * composeFileURL *** -->
289 <!-- ****************************** -->
290 <xsl:template name=
"composeFileURL">
291 <xsl:param name=
"componentName"/>
292 <xsl:variable name=
"fileURL">
293 <xsl:value-of select=
"$schemaRootURL"/>/
<xsl:value-of select=
"translate($componentName,'.','/')"/><xsl:text>.xcs
</xsl:text>
295 <xsl:value-of select=
"$fileURL"/>