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 2008 by Sun Microsystems, Inc.
8 OpenOffice.org - a multi-platform office productivity suite
10 $RCSfile: schema_val.xsl,v $
14 This file is part of OpenOffice.org.
16 OpenOffice.org is free software: you can redistribute it and/or modify
17 it under the terms of the GNU Lesser General Public License version 3
18 only, as published by the Free Software Foundation.
20 OpenOffice.org is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU Lesser General Public License version 3 for more details
24 (a copy is included in the LICENSE file that accompanied this code).
26 You should have received a copy of the GNU Lesser General Public License
27 version 3 along with OpenOffice.org. If not, see
28 <http://www.openoffice.org/license.html>
29 for a copy of the LGPLv3 License.
31 ************************************************************************ -->
33 <xsl:transform xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
34 xmlns:
xsi=
"http://www.w3.org/2001/XMLSchema-instance"
35 xmlns:
xs=
"http://www.w3.org/2001/XMLSchema"
36 xmlns:
oor=
"http://openoffice.org/2001/registry"
39 <!-- Get the correct format -->
40 <xsl:output method=
"xml" indent=
"yes"/>
41 <xsl:namespace-alias stylesheet-prefix=
"xs" result-prefix=
"xs"></xsl:namespace-alias>
44 <xsl:param name=
"root">../registry/schema
</xsl:param>
45 <xsl:param name=
"componentName"/>
47 <xsl:template match =
"/">
48 <xsl:message terminate=
"no">CHECKING CONSISTENCY ...
</xsl:message>
49 <xsl:apply-templates/>
52 <!-- activate attribute templates -->
53 <xsl:template match=
"group|set|prop">
54 <xsl:apply-templates select=
"*|@*"/>
57 <!-- make sure that missing features are not invoked -->
58 <xsl:template match =
"item">
59 <xsl:message terminate=
"yes">ERROR: multiple template types for sets are NOT supported!
</xsl:message>
62 <xsl:template match =
"set[@oor:extensible='true']">
63 <xsl:message terminate=
"yes">ERROR: extensible sets are currently NOT supported!
</xsl:message>
66 <xsl:template match =
"group[@oor:extensible='true']">
67 <xsl:if test=
"count(child::set) or count(child::group) or count(child::node-ref)">
68 <xsl:message terminate=
"yes">ERROR: extensible groups with children are currently NOT supported!
</xsl:message>
70 <xsl:apply-templates select=
"*|@*"/>
73 <!-- Localized info elements (desc/label) are not supported currently -->
74 <xsl:template match=
"info//*[@xml:lang]">
75 <xsl:message terminate=
"yes">ERROR: Info elements (desc/label) are currently not localized. Remove xml:lang attributes!
</xsl:message>
78 <!-- check for duplicate child names -->
79 <xsl:template match=
"@oor:name">
80 <xsl:variable name=
"item-name" select=
"."/>
81 <xsl:if test=
"../following-sibling::*[@oor:name = $item-name]">
82 <xsl:message terminate=
"yes">ERROR: Duplicate node name '
<xsl:value-of select=
"$item-name"/>'!
</xsl:message>
86 <!-- check if properties of type 'any' do not have a value -->
87 <xsl:template match=
"prop[@oor:type='oor:any']">
88 <xsl:if test=
"count(value)">
89 <xsl:message terminate=
"yes">ERROR: Properties of type 'oor:any' MUST NOT have a value!
</xsl:message>
91 <xsl:apply-templates select=
"*|@*"/>
94 <!-- inhibit (explicit) NIL values -->
95 <xsl:template match=
"value[@xsi:nil]">
96 <xsl:message terminate=
"yes">ERROR: xsi:nil is not allowed in schemas !
</xsl:message>
99 <!-- validate for correct node references -->
100 <xsl:template match=
"@oor:node-type">
102 <xsl:when test=
"../@oor:component">
103 <xsl:variable name =
"file">
104 <xsl:call-template name=
"locateFile"><xsl:with-param name=
"componentName" select=
"../@oor:component"/></xsl:call-template>
106 <xsl:if test=
"not(document($file)/oor:component-schema/templates/*[@oor:name=current()])">
107 <xsl:message terminate=
"yes">ERROR: node-type '
<xsl:value-of select=
"current()"/>' not found!
</xsl:message>
110 <xsl:when test=
"not(/oor:component-schema/templates/*[@oor:name=current()])">
111 <xsl:message terminate=
"yes">ERROR: node-type '
<xsl:value-of select=
"current()"/>' not found!
</xsl:message>
116 <!-- validate if file name matches component-name -->
117 <xsl:template match=
"oor:component-schema">
118 <xsl:variable name =
"fullName"><xsl:value-of select=
"@oor:package"/>.
<xsl:value-of select=
"@oor:name"/></xsl:variable>
119 <xsl:if test=
"$fullName != $componentName">
120 <xsl:message terminate=
"yes">ERROR: Component name '
<xsl:value-of select=
"$fullName"/>' does not match with file name!
</xsl:message>
122 <xsl:apply-templates select=
"*|@*"/>
126 <!-- locate a component file -->
127 <xsl:template name=
"locateFile">
128 <xsl:param name=
"componentName"/>
129 <xsl:variable name =
"file"><xsl:value-of select=
"$root"/>/
<xsl:value-of select=
"translate($componentName,'.','/')"/>.xcs
</xsl:variable>
130 <xsl:if test=
"not( document($file) )">
131 <xsl:message terminate =
"yes">**Error: unable to locate document '
<xsl:value-of select=
"translate($componentName,'.','/')"/>.xcd'
</xsl:message>
133 <xsl:value-of select=
"$file"/>