update dev300-m58
[ooovba.git] / officecfg / util / schema_val.xsl
blob09655938d84262fafc73c366189d836f4c46b97e
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 $
12 $Revision: 1.11 $
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"
37 version="1.0">
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>
43 <!-- Parameter -->
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/>
50 </xsl:template>
52 <!-- activate attribute templates -->
53 <xsl:template match="group|set|prop">
54 <xsl:apply-templates select="*|@*"/>
55 </xsl:template>
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>
60 </xsl:template>
62 <xsl:template match = "set[@oor:extensible='true']">
63 <xsl:message terminate="yes">ERROR: extensible sets are currently NOT supported!</xsl:message>
64 </xsl:template>
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>
69 </xsl:if>
70 <xsl:apply-templates select="*|@*"/>
71 </xsl:template>
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>
76 </xsl:template>
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>
83 </xsl:if>
84 </xsl:template>
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>
90 </xsl:if>
91 <xsl:apply-templates select="*|@*"/>
92 </xsl:template>
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>
97 </xsl:template>
99 <!-- validate for correct node references -->
100 <xsl:template match="@oor:node-type">
101 <xsl:choose>
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>
105 </xsl:variable>
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>
108 </xsl:if>
109 </xsl:when>
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>
112 </xsl:when>
113 </xsl:choose>
114 </xsl:template>
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>
121 </xsl:if>
122 <xsl:apply-templates select="*|@*"/>
123 </xsl:template>
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>
132 </xsl:if>
133 <xsl:value-of select="$file"/>
134 </xsl:template>
136 </xsl:transform>