fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / officecfg / util / schema_val.xsl
blob4161808af2d24384c21418c9e9dd655aec018d45
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 <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
21 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22 xmlns:xs="http://www.w3.org/2001/XMLSchema"
23 xmlns:oor="http://openoffice.org/2001/registry"
24 version="1.0">
26 <!-- Get the correct format -->
27 <xsl:output method="xml" indent="yes"/>
28 <xsl:namespace-alias stylesheet-prefix="xs" result-prefix="xs"></xsl:namespace-alias>
30 <!-- Parameter -->
31 <xsl:param name="root">../registry/schema</xsl:param>
32 <xsl:param name="schemaRoot"/>
33 <xsl:param name="componentName"/>
35 <xsl:template match = "/">
36 <xsl:apply-templates/>
37 </xsl:template>
39 <!-- activate attribute templates -->
40 <xsl:template match="group|set|prop">
41 <xsl:apply-templates select="*|@*"/>
42 </xsl:template>
44 <!-- make sure that missing features are not invoked -->
45 <xsl:template match = "item">
46 <xsl:message terminate="yes">ERROR: multiple template types for sets are NOT supported!</xsl:message>
47 </xsl:template>
49 <xsl:template match = "set[@oor:extensible='true']">
50 <xsl:message terminate="yes">ERROR: extensible sets are currently NOT supported!</xsl:message>
51 </xsl:template>
53 <xsl:template match = "group[@oor:extensible='true']">
54 <xsl:if test="count(child::set) or count(child::group) or count(child::node-ref)">
55 <xsl:message terminate="yes">ERROR: extensible groups with children are currently NOT supported!</xsl:message>
56 </xsl:if>
57 <xsl:apply-templates select="*|@*"/>
58 </xsl:template>
60 <!-- Localized info elements (desc/label) are not supported currently -->
61 <xsl:template match="info//*[@xml:lang]">
62 <xsl:message terminate="yes">ERROR: Info elements (desc/label) are currently not localized. Remove xml:lang attributes!</xsl:message>
63 </xsl:template>
65 <!-- check for duplicate child names -->
66 <xsl:template match="@oor:name">
67 <xsl:variable name="item-name" select="."/>
68 <xsl:if test="../following-sibling::*[@oor:name = $item-name]">
69 <xsl:message terminate="yes">ERROR: Duplicate node name '<xsl:value-of select="$item-name"/>'!</xsl:message>
70 </xsl:if>
71 </xsl:template>
73 <!-- check if properties of type 'any' do not have a value -->
74 <xsl:template match="prop[@oor:type='oor:any']">
75 <xsl:if test="count(value)">
76 <xsl:message terminate="yes">ERROR: Properties of type 'oor:any' MUST NOT have a value!</xsl:message>
77 </xsl:if>
78 <xsl:apply-templates select="*|@*"/>
79 </xsl:template>
81 <!-- inhibit (explicit) NIL values -->
82 <xsl:template match="value[@xsi:nil]">
83 <xsl:message terminate="yes">ERROR: xsi:nil is not allowed in schemas !</xsl:message>
84 </xsl:template>
86 <!-- validate for correct node references -->
87 <xsl:template match="@oor:node-type">
88 <xsl:choose>
89 <xsl:when test="../@oor:component">
90 <xsl:variable name ="file">
91 <xsl:call-template name="locateFile"><xsl:with-param name="componentName" select="../@oor:component"/></xsl:call-template>
92 </xsl:variable>
93 <xsl:if test="not(document($file)/oor:component-schema/templates/*[@oor:name=current()])">
94 <xsl:message terminate="yes">ERROR: node-type '<xsl:value-of select="current()"/>' not found!</xsl:message>
95 </xsl:if>
96 </xsl:when>
97 <xsl:when test="not(/oor:component-schema/templates/*[@oor:name=current()])">
98 <xsl:message terminate="yes">ERROR: node-type '<xsl:value-of select="current()"/>' not found!</xsl:message>
99 </xsl:when>
100 </xsl:choose>
101 </xsl:template>
103 <!-- validate if file name matches component-name -->
104 <xsl:template match="oor:component-schema">
105 <xsl:variable name ="fullName"><xsl:value-of select="@oor:package"/>.<xsl:value-of select="@oor:name"/></xsl:variable>
106 <xsl:if test="$fullName != $componentName">
107 <xsl:message terminate="yes">ERROR: Component name '<xsl:value-of select="$fullName"/>' does not match with file name!</xsl:message>
108 </xsl:if>
109 <xsl:apply-templates select="*|@*"/>
110 </xsl:template>
113 <!-- locate a component file -->
114 <xsl:template name="locateFile">
115 <xsl:param name="componentName"/>
116 <xsl:variable name="path"><xsl:value-of select="translate($componentName,'.','/')"/>.xcs</xsl:variable>
117 <xsl:variable name ="file">
118 <xsl:variable name ="tryfile" select="concat($root,'/',$path)"/>
119 <xsl:choose>
120 <xsl:when test="document($tryfile)">
121 <xsl:value-of select="$tryfile"/>
122 </xsl:when>
123 <xsl:otherwise>
124 <xsl:if test="$schemaRoot">
125 <xsl:variable name="globalfile" select="concat($schemaRoot,'/',$path)"/>
126 <xsl:if test="document($globalfile)">
127 <xsl:value-of select="$globalfile"/>
128 </xsl:if>
129 </xsl:if>
130 </xsl:otherwise>
131 </xsl:choose>
132 </xsl:variable>
133 <xsl:if test="not($file)">
134 <xsl:message terminate ="yes">**Error: unable to locate document '<xsl:value-of select="$path"/>'</xsl:message>
135 </xsl:if>
136 <xsl:value-of select="$file"/>
137 </xsl:template>
139 </xsl:transform>