2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
22 xmlns:
rng=
"http://relaxng.org/ns/structure/1.0"
23 xml:
space=
"default" xml:
indent=
"true">
24 <xsl:output method=
"text" />
26 <xsl:template name=
"noannotation">
27 <xsl:for-each select=
"//namespace">
28 <xsl:variable name=
"nsname" select=
"@name"/>
29 <xsl:value-of select=
"./rng:grammar/@ns"/>
30 <xsl:text>
</xsl:text>
31 <xsl:for-each select=
".//rng:define">
32 <xsl:variable name=
"name" select=
"@name"/>
33 <xsl:if test=
"not(ancestor::namespace//resource[@name=$name])">
34 <xsl:text>noannotation:
</xsl:text>
35 <xsl:value-of select=
"$nsname"/>
36 <xsl:text>::
</xsl:text>
37 <xsl:value-of select=
"$name"/>
38 <xsl:text>
</xsl:text>
44 <xsl:template name=
"checkmodel">
45 <xsl:for-each select=
"//namespace">
46 <xsl:variable name=
"nsname" select=
"@name"/>
47 <xsl:for-each select=
".//rng:define">
48 <xsl:call-template name=
"orphanedprops"/>
49 <xsl:variable name=
"definename" select=
"@name"/>
50 <xsl:if test=
"not(ancestor::namespace//resource[@name=$definename])">
51 <xsl:text>no annotation:
</xsl:text>
52 <xsl:value-of select=
"$nsname"/>
53 <xsl:text>::
</xsl:text>
54 <xsl:value-of select=
"$definename"/>
55 <xsl:text>
</xsl:text>
57 <xsl:for-each select=
".//rng:element">
58 <xsl:variable name=
"elementname" select=
"@name"/>
59 <xsl:for-each select=
"ancestor::namespace//resource[@name=$definename and @resource='Properties']">
60 <xsl:if test=
"not(.//element[@name=$elementname])">
61 <xsl:text>missing element:
</xsl:text>
62 <xsl:value-of select=
"$nsname"/>
63 <xsl:text>::
</xsl:text>
64 <xsl:value-of select=
"$definename"/>
65 <xsl:text>::
</xsl:text>
66 <xsl:value-of select=
"$elementname"/>
67 <xsl:text>
</xsl:text>
69 <xsl:call-template name=
"orphanedprops"/>
72 <xsl:for-each select=
".//rng:attribute">
73 <xsl:variable name=
"attributename" select=
"@name"/>
74 <xsl:for-each select=
"ancestor::namespace//resource[@name=$definename and @resource='Properties']">
75 <xsl:if test=
"not(.//attribute[@name=$attributename])">
76 <xsl:text>missing attribute:
</xsl:text>
77 <xsl:value-of select=
"$nsname"/>
78 <xsl:text>::
</xsl:text>
79 <xsl:value-of select=
"$definename"/>
80 <xsl:text>::
</xsl:text>
81 <xsl:value-of select=
"$attributename"/>
82 <xsl:text>
</xsl:text>
84 <xsl:call-template name=
"orphanedprops"/>
91 <xsl:key name=
"defines-with-name" match=
"rng:define" use=
"@name"/>
93 <xsl:template name=
"defineforref">
94 <xsl:variable name=
"grammarid" select=
"generate-id(ancestor::grammar)"/>
95 <xsl:variable name=
"defineingrammar" select=
"key('defines-with-name', @name)[generate-id(ancestor::grammar) = $grammarid]"/>
97 <xsl:when test=
"$defineingrammar">
98 <xsl:value-of select=
"$defineingrammar"/>
101 <xsl:value-of select=
"key('defines-with-name', @name)"/>
106 <xsl:template name=
"contextresource">
107 <xsl:variable name=
"name" select=
"@name"/>
108 <xsl:value-of select=
"ancestor::namespace//resource[@name=$name]/@resource"/>
111 <xsl:template name=
"orphanedprops">
112 <xsl:variable name=
"nsname" select=
"ancestor::namespace/@name"/>
113 <xsl:for-each select=
".//rng:ref[not (ancestor::rng:element or ancestor::rng:attribute)]">
114 <xsl:variable name=
"defineresource">
115 <xsl:for-each select=
"ancestor::rng:define">
116 <xsl:call-template name=
"contextresource"/>
119 <xsl:variable name=
"definename" select=
"ancestor::rng:define/@name"/>
120 <xsl:variable name=
"mydefine">
122 <xsl:call-template name=
"defineforref"/>
125 <xsl:variable name=
"myresource">
126 <xsl:call-template name=
"contextresource"/>
128 <xsl:if test=
"$myresource = 'Properties'">
130 <xsl:when test=
"$defineresource = 'Properties'"/>
131 <xsl:when test=
"$defineresource = 'Stream'"/>
133 <xsl:text>orphaned properties:
</xsl:text>
134 <xsl:value-of select=
"$nsname"/>
135 <xsl:text>:
</xsl:text>
136 <xsl:value-of select=
"$definename"/>
137 <xsl:text>(
</xsl:text>
138 <xsl:value-of select=
"$defineresource"/>
139 <xsl:text>)-
></xsl:text>
140 <xsl:value-of select=
"@name"/>
141 <xsl:text>(
</xsl:text>
142 <xsl:value-of select=
"$myresource"/>
143 <xsl:text>)

</xsl:text>
150 <xsl:template match=
"/">
152 <xsl:call-template name=
"checkmodel"/>