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 <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"
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>
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/>
39 <!-- activate attribute templates -->
40 <xsl:template match=
"group|set|prop">
41 <xsl:apply-templates select=
"*|@*"/>
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>
49 <xsl:template match =
"set[@oor:extensible='true']">
50 <xsl:message terminate=
"yes">ERROR: extensible sets are currently NOT supported!
</xsl:message>
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>
57 <xsl:apply-templates select=
"*|@*"/>
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>
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>
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>
78 <xsl:apply-templates select=
"*|@*"/>
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>
86 <!-- validate for correct node references -->
87 <xsl:template match=
"@oor:node-type">
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>
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>
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>
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>
109 <xsl:apply-templates select=
"*|@*"/>
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)"/>
120 <xsl:when test=
"document($tryfile)">
121 <xsl:value-of select=
"$tryfile"/>
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"/>
133 <xsl:if test=
"not($file)">
134 <xsl:message terminate =
"yes">**Error: unable to locate document '
<xsl:value-of select=
"$path"/>'
</xsl:message>
136 <xsl:value-of select=
"$file"/>