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: modelcleanup.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 xmlns:
xalan=
"http://xml.apache.org/xalan"
39 exclude-result-prefixes =
"xalan"
41 <xsl:output method=
"xml" />
44 <xsl:key name=
"resources"
45 match=
"resource[not(@generated)]" use=
"@name" />
47 <xsl:template name=
"generateresource">
48 <xsl:param name=
"resource"/>
49 <xsl:element name=
"resource">
50 <xsl:attribute name=
"name">
51 <xsl:value-of select=
"@name"/>
53 <xsl:attribute name=
"resource">
54 <xsl:value-of select=
"$resource"/>
56 <xsl:attribute name=
"generated">
57 <xsl:text>yes
</xsl:text>
62 <xsl:key name=
"nsaliases" match=
"//namespace-alias" use=
"@name"/>
64 <xsl:template name=
"resourcevalues">
65 <xsl:variable name=
"definename" select=
"@name"/>
66 <xsl:variable name=
"namespace" select=
"key('nsaliases', ancestor::namespace/rng:grammar/@ns)/@alias"/>
67 <xsl:element name=
"resource">
68 <xsl:attribute name=
"name">
69 <xsl:value-of select=
"@name"/>
71 <xsl:attribute name=
"resource">List
</xsl:attribute>
72 <xsl:attribute name=
"generated">yes
</xsl:attribute>
73 <xsl:for-each select=
".//rng:value">
74 <xsl:element name=
"value">
75 <xsl:attribute name=
"name">
76 <xsl:value-of select=
"translate(., '-+ ,', 'mp__')"/>
78 <xsl:attribute name=
"tokenid">
79 <xsl:text>ooxml:Value_
</xsl:text>
80 <xsl:value-of select=
"translate($namespace, '-', '_')"/>
81 <xsl:text>_
</xsl:text>
82 <xsl:value-of select=
"$definename"/>
83 <xsl:text>_
</xsl:text>
84 <xsl:value-of select=
"translate(., '-+ ,', 'mp__')"/>
86 <xsl:value-of select=
"."/>
92 <xsl:template match=
"namespace">
93 <xsl:variable name=
"nsid" select=
"generate-id(.)"/>
94 <xsl:element name=
"namespace">
95 <xsl:copy-of select=
"@*"/>
96 <xsl:copy-of select=
".//start"/>
97 <xsl:copy-of select=
"./rng:grammar"/>
99 <xsl:for-each select=
".//rng:define">
100 <xsl:variable name=
"resources" select=
"key('resources', @name)[generate-id(ancestor::namespace) = $nsid]"/>
101 <xsl:copy-of select=
"$resources"/>
102 <xsl:if test=
"count($resources) = 0">
103 <xsl:if test=
"substring(@name, 1, 3) = 'CT_'">
104 <xsl:if test=
"./rng:attribute[@name='val']/rng:text">
105 <xsl:call-template name=
"generateresource">
106 <xsl:with-param name=
"resource">StringValue
</xsl:with-param>
110 <xsl:if test=
"substring(@name, 1, 3) = 'ST_'">
111 <xsl:if test=
"./rng:data[@type='int']">
112 <xsl:call-template name=
"generateresource">
113 <xsl:with-param name=
"resource">Integer
</xsl:with-param>
116 <xsl:if test=
"./rng:data[@type='integer']">
117 <xsl:call-template name=
"generateresource">
118 <xsl:with-param name=
"resource">Integer
</xsl:with-param>
121 <xsl:if test=
"./rng:data[@type='long']">
122 <xsl:call-template name=
"generateresource">
123 <xsl:with-param name=
"resource">Integer
</xsl:with-param>
126 <xsl:if test=
"./rng:data[@type='unsignedInt']">
127 <xsl:call-template name=
"generateresource">
128 <xsl:with-param name=
"resource">Integer
</xsl:with-param>
131 <xsl:if test=
"./rng:data[@type='unsignedLong']">
132 <xsl:call-template name=
"generateresource">
133 <xsl:with-param name=
"resource">Integer
</xsl:with-param>
136 <xsl:if test=
"./rng:data[@type='boolean']">
137 <xsl:call-template name=
"generateresource">
138 <xsl:with-param name=
"resource">Boolean
</xsl:with-param>
141 <xsl:if test=
"./rng:data[@type='token']">
142 <xsl:call-template name=
"generateresource">
143 <xsl:with-param name=
"resource">String
</xsl:with-param>
146 <xsl:if test=
"./rng:data[@type='string']">
147 <xsl:call-template name=
"generateresource">
148 <xsl:with-param name=
"resource">String
</xsl:with-param>
151 <xsl:if test=
"./rng:data[@type='dateTime']">
152 <xsl:call-template name=
"generateresource">
153 <xsl:with-param name=
"resource">String
</xsl:with-param>
156 <xsl:if test=
"./rng:data[@type='hexBinary']">
157 <xsl:call-template name=
"generateresource">
158 <xsl:with-param name=
"resource">Hex
</xsl:with-param>
161 <xsl:if test=
"./rng:list">
162 <xsl:call-template name=
"resourcevalues"/>
170 <xsl:template match=
"namespace-alias">
172 <xsl:for-each select=
"@*">
173 <xsl:copy-of select=
"."/>
178 <xsl:template match=
"token">
180 <xsl:for-each select=
"@*">
181 <xsl:copy-of select=
"."/>
186 <xsl:template match=
"fasttoken">
187 <xsl:copy-of select=
"."/>
190 <xsl:template match=
"/">
192 <xsl:apply-templates select=
".//namespace-alias">
193 <xsl:sort select=
"@id" data-type=
"number"/>
194 </xsl:apply-templates>
195 <xsl:apply-templates select=
".//token"/>
196 <xsl:apply-templates select=
".//fasttoken"/>
197 <xsl:apply-templates select=
".//namespace"/>