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: checkmodel.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 ************************************************************************/
36 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
37 xmlns:
rng=
"http://relaxng.org/ns/structure/1.0"
38 xml:
space=
"default" xml:
indent=
"true">
39 <xsl:output method=
"text" />
42 <xsl:template name=
"noannotation">
43 <xsl:for-each select=
"//namespace">
44 <xsl:variable name=
"nsname" select=
"@name"/>
45 <xsl:value-of select=
"./rng:grammar/@ns"/>
46 <xsl:text>
</xsl:text>
47 <xsl:for-each select=
".//rng:define">
48 <xsl:variable name=
"name" select=
"@name"/>
49 <xsl:if test=
"not(ancestor::namespace//resource[@name=$name])">
50 <xsl:text>noannotation:
</xsl:text>
51 <xsl:value-of select=
"$nsname"/>
52 <xsl:text>::
</xsl:text>
53 <xsl:value-of select=
"$name"/>
54 <xsl:text>
</xsl:text>
60 <xsl:template name=
"checkmodel">
61 <xsl:for-each select=
"//namespace">
62 <xsl:variable name=
"nsname" select=
"@name"/>
63 <xsl:for-each select=
".//rng:define">
64 <xsl:call-template name=
"orphanedprops"/>
65 <xsl:variable name=
"definename" select=
"@name"/>
66 <xsl:if test=
"not(ancestor::namespace//resource[@name=$definename])">
67 <xsl:text>no annotation:
</xsl:text>
68 <xsl:value-of select=
"$nsname"/>
69 <xsl:text>::
</xsl:text>
70 <xsl:value-of select=
"$definename"/>
71 <xsl:text>
</xsl:text>
73 <xsl:for-each select=
".//rng:element">
74 <xsl:variable name=
"elementname" select=
"@name"/>
75 <xsl:for-each select=
"ancestor::namespace//resource[@name=$definename and @resource='Properties']">
76 <xsl:if test=
"not(.//element[@name=$elementname])">
77 <xsl:text>missing element:
</xsl:text>
78 <xsl:value-of select=
"$nsname"/>
79 <xsl:text>::
</xsl:text>
80 <xsl:value-of select=
"$definename"/>
81 <xsl:text>::
</xsl:text>
82 <xsl:value-of select=
"$elementname"/>
83 <xsl:text>
</xsl:text>
85 <xsl:call-template name=
"orphanedprops"/>
88 <xsl:for-each select=
".//rng:attribute">
89 <xsl:variable name=
"attributename" select=
"@name"/>
90 <xsl:for-each select=
"ancestor::namespace//resource[@name=$definename and @resource='Properties']">
91 <xsl:if test=
"not(.//attribute[@name=$attributename])">
92 <xsl:text>missing attribute:
</xsl:text>
93 <xsl:value-of select=
"$nsname"/>
94 <xsl:text>::
</xsl:text>
95 <xsl:value-of select=
"$definename"/>
96 <xsl:text>::
</xsl:text>
97 <xsl:value-of select=
"$attributename"/>
98 <xsl:text>
</xsl:text>
100 <xsl:call-template name=
"orphanedprops"/>
107 <xsl:key name=
"defines-with-name" match=
"rng:define" use=
"@name"/>
109 <xsl:template name=
"defineforref">
110 <xsl:variable name=
"grammarid" select=
"generate-id(ancestor::grammar)"/>
111 <xsl:variable name=
"defineingrammar" select=
"key('defines-with-name', @name)[generate-id(ancestor::grammar) = $grammarid]"/>
113 <xsl:when test=
"$defineingrammar">
114 <xsl:value-of select=
"$defineingrammar"/>
117 <xsl:value-of select=
"key('defines-with-name', @name)"/>
122 <xsl:template name=
"contextresource">
123 <xsl:variable name=
"name" select=
"@name"/>
124 <xsl:value-of select=
"ancestor::namespace//resource[@name=$name]/@resource"/>
127 <xsl:template name=
"orphanedprops">
128 <xsl:variable name=
"nsname" select=
"ancestor::namespace/@name"/>
129 <xsl:for-each select=
".//rng:ref[not (ancestor::rng:element or ancestor::rng:attribute)]">
130 <xsl:variable name=
"defineresource">
131 <xsl:for-each select=
"ancestor::rng:define">
132 <xsl:call-template name=
"contextresource"/>
135 <xsl:variable name=
"definename" select=
"ancestor::rng:define/@name"/>
136 <xsl:variable name=
"mydefine">
138 <xsl:call-template name=
"defineforref"/>
141 <xsl:variable name=
"myresource">
142 <xsl:call-template name=
"contextresource"/>
144 <xsl:if test=
"$myresource = 'Properties'">
146 <xsl:when test=
"$defineresource = 'Properties'"/>
147 <xsl:when test=
"$defineresource = 'Stream'"/>
149 <xsl:text>orphaned properties:
</xsl:text>
150 <xsl:value-of select=
"$nsname"/>
151 <xsl:text>:
</xsl:text>
152 <xsl:value-of select=
"$definename"/>
153 <xsl:text>(
</xsl:text>
154 <xsl:value-of select=
"$defineresource"/>
155 <xsl:text>)-
></xsl:text>
156 <xsl:value-of select=
"@name"/>
157 <xsl:text>(
</xsl:text>
158 <xsl:value-of select=
"$myresource"/>
159 <xsl:text>)

</xsl:text>
166 <xsl:template match=
"/">
168 <xsl:call-template name=
"checkmodel"/>