fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / officecfg / util / data_val.xsl
blobcd2f10e8743768835efab2c22440307ee87ad211
1 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
2 <!--
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 .
18 -->
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"/>
37 </xsl:variable>
38 <xsl:variable name="schemaURL">
39 <xsl:value-of select="$xcs"/>
40 </xsl:variable>
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>
52 </xsl:for-each>
53 </xsl:template>
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"/>
64 </xsl:variable>
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!
70 </xsl:message>
71 </xsl:if>
73 <xsl:choose>
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>
79 </xsl:when>
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>
86 </xsl:for-each>
87 </xsl:when>
88 <xsl:otherwise>
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.
91 </xsl:message>
92 </xsl:otherwise>
93 </xsl:choose>
94 </xsl:template>
96 <!-- ****************************************** -->
97 <!-- * node *** -->
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"/>
104 </xsl:variable>
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>
108 </xsl:if>
110 <xsl:call-template name="checkModule"/>
111 <xsl:call-template name="checkDuplicates"/>
113 <xsl:choose>
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>
119 </xsl:call-template>
120 </xsl:variable>
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"/>
126 </xsl:call-template>
127 </xsl:when>
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"/>
134 </xsl:call-template>
135 </xsl:when>
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>
143 </xsl:for-each>
144 </xsl:when>
145 <xsl:otherwise>
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>
151 </xsl:for-each>
152 </xsl:otherwise>
153 </xsl:choose>
154 </xsl:template>
156 <!-- ****************************************** -->
157 <!-- * prop *** -->
158 <!-- ****************************************** -->
159 <xsl:template match="prop">
160 <xsl:param name = "context"/>
161 <xsl:variable name = "path">
162 <xsl:call-template name="collectPath"/>
163 </xsl:variable>
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>
168 </xsl:if>
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>
172 </xsl:if>
174 <xsl:call-template name="checkModule"/>
175 <xsl:call-template name="checkDuplicates"/>
177 <xsl:apply-templates />
178 </xsl:template>
180 <!-- ****************************************** -->
181 <!-- * value *** -->
182 <!-- ****************************************** -->
183 <xsl:template match="value">
184 <xsl:call-template name="checkModule"/>
185 <xsl:variable name="path">
186 <xsl:call-template name="collectPath"/>
187 </xsl:variable>
188 <xsl:variable name="lang" select="@xml:lang"/>
189 <xsl:variable name="module" select="@install:module"/>
190 <xsl:if test="$module and $lang='x-no-translate'">
191 <xsl:message terminate="yes">ERROR: Property '<xsl:value-of select="$path"/>' has value for special xml:lang="x-no-translate" in module <xsl:value-of select="$module"/>.</xsl:message>
192 </xsl:if>
193 <xsl:choose>
194 <xsl:when
195 test="preceding-sibling::value[($lang and not(@xml:lang)) or (not($lang) and @xml:lang)]">
196 <xsl:message terminate="yes">ERROR: Property '<xsl:value-of select="$path"/>' has values with and without xml:lang attributes.</xsl:message>
197 </xsl:when>
198 <xsl:when
199 test="preceding-sibling::value[((not($lang) and not(@xml:lang)) or $lang=@xml:lang) and ((not($module) and not(@install:module)) or $module=@install:module)]">
200 <xsl:message terminate="yes">ERROR: Property '<xsl:value-of select="$path"/>' has values with matching xml:lang attribute <xsl:value-of select="$lang"/> and inconsistent install:module attributes.</xsl:message>
201 </xsl:when>
202 <xsl:when
203 test="preceding-sibling::value[((not($lang) and not(@xml:lang)) or $lang=@xml:lang) and (($module and not(@install:module)) or (not($module) and @install:module) or $module!=@install:module)]">
204 <xsl:message>ATTENTION: Property '<xsl:value-of select="$path"/>' has different values for different modules. Make sure the modules are mutually exclusive!</xsl:message>
205 </xsl:when>
206 </xsl:choose>
207 </xsl:template>
209 <!-- ****************************************** -->
210 <!-- * node (mode:extensible) - not supported * -->
211 <!-- ****************************************** -->
212 <xsl:template match="node" mode="extensible">
213 <xsl:variable name = "path">
214 <xsl:call-template name="collectPath"/>
215 </xsl:variable>
217 <xsl:message terminate="yes">ERROR: Node '<xsl:value-of select="$path"/>' is within an extensible node!</xsl:message>
218 </xsl:template>
219 <!-- ****************************************** -->
220 <!-- * prop (mode:extensible) *** -->
221 <!-- ****************************************** -->
222 <xsl:template match="prop" mode="extensible">
223 <xsl:param name = "context"/>
224 <xsl:variable name = "path">
225 <xsl:call-template name="collectPath"/>
226 </xsl:variable>
228 <xsl:choose>
229 <xsl:when test="not(@oor:op)">
230 <xsl:if test="not ($context)">
231 <xsl:message terminate="yes">ERROR: Property '<xsl:value-of select="$path"/>' does not exist in schema!</xsl:message>
232 </xsl:if>
233 </xsl:when>
234 <xsl:when test="@oor:op='replace'">
235 <xsl:if test="not (@oor:type)">
236 <xsl:message terminate="yes">ERROR: Property '<xsl:value-of select="$path"/>' does not have a type!</xsl:message>
237 </xsl:if>
238 </xsl:when>
239 <xsl:otherwise>
240 <xsl:message terminate="yes">ERROR: Property '<xsl:value-of select="$path"/>' has unexpected operation '<xsl:value-of select="@oor:op"/>'!</xsl:message>
241 </xsl:otherwise>
242 </xsl:choose>
244 <xsl:call-template name="checkModule"/>
245 <xsl:call-template name="checkDuplicates"/>
246 </xsl:template>
249 <!-- ************************************* -->
250 <!-- * checkDuplicates *** -->
251 <!-- ************************************* -->
252 <xsl:template name="checkDuplicates">
253 <xsl:variable name="item-name" select="@oor:name"/>
254 <xsl:if test="following-sibling::*[@oor:name = $item-name]">
255 <xsl:variable name = "path">
256 <xsl:call-template name="collectPath"/>
257 </xsl:variable>
258 <xsl:message terminate="yes">ERROR: Duplicate node/prop '<xsl:value-of select="$path"/>'!</xsl:message>
259 </xsl:if>
260 </xsl:template>
263 <!-- ************************************* -->
264 <!-- * checkModule *** -->
265 <!-- ************************************* -->
266 <xsl:template name="checkModule">
267 <xsl:if test="@install:module">
268 <xsl:if test="ancestor::*[@install:module]">
269 <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"/>'!
270 </xsl:message>
271 </xsl:if>
272 </xsl:if>
273 </xsl:template>
275 <!-- ************************************* -->
276 <!-- * collectPath *** -->
277 <!-- ************************************* -->
278 <xsl:template name="collectPath">
279 <xsl:for-each select="ancestor-or-self::node()[@oor:name]">
280 <xsl:text>/</xsl:text><xsl:value-of select="@oor:name"/>
281 </xsl:for-each>
282 </xsl:template>
285 <!-- ****************************** -->
286 <!-- * composeFileURL *** -->
287 <!-- ****************************** -->
288 <xsl:template name="composeFileURL">
289 <xsl:param name="componentName"/>
290 <xsl:variable name="fileURL">
291 <xsl:value-of select="$schemaRootURL"/>/<xsl:value-of select="translate($componentName,'.','/')"/><xsl:text>.xcs</xsl:text>
292 </xsl:variable>
293 <xsl:value-of select="$fileURL"/>
294 </xsl:template>
297 </xsl:transform>