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 .
20 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
21 xmlns:
office=
"urn:oasis:names:tc:opendocument:xmlns:office:1.0"
22 xmlns:
style=
"urn:oasis:names:tc:opendocument:xmlns:style:1.0"
23 xmlns:
text=
"urn:oasis:names:tc:opendocument:xmlns:text:1.0"
24 xmlns:
table=
"urn:oasis:names:tc:opendocument:xmlns:table:1.0"
25 xmlns:
draw=
"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
26 xmlns:
fo=
"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
27 xmlns:
xlink=
"http://www.w3.org/1999/xlink"
28 xmlns:
dc=
"http://purl.org/dc/elements/1.1/"
29 xmlns:
meta=
"urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
30 xmlns:
number=
"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
31 xmlns:
svg=
"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
32 xmlns:
chart=
"urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
33 xmlns:
dr3d=
"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
34 xmlns:
math=
"http://www.w3.org/1998/Math/MathML"
35 xmlns:
form=
"urn:oasis:names:tc:opendocument:xmlns:form:1.0"
36 xmlns:
script=
"urn:oasis:names:tc:opendocument:xmlns:script:1.0"
37 xmlns:
config=
"urn:oasis:names:tc:opendocument:xmlns:config:1.0"
38 xmlns:
ooo=
"http://openoffice.org/2004/office"
39 xmlns:
ooow=
"http://openoffice.org/2004/writer"
40 xmlns:
oooc=
"http://openoffice.org/2004/calc"
41 xmlns:
dom=
"http://www.w3.org/2001/xml-events"
42 xmlns:
xforms=
"http://www.w3.org/2002/xforms"
43 xmlns:
xsd=
"http://www.w3.org/2001/XMLSchema"
44 xmlns:
xsi=
"http://www.w3.org/2001/XMLSchema-instance"
45 xmlns:
rdf=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
46 xmlns:
rng=
"http://relaxng.org/ns/structure/1.0"
47 xmlns:
rdfs=
"http://www.w3.org/2000/01/rdf-schema#"
48 xmlns:
xalan=
"http://xml.apache.org/xalan"
49 xmlns:UML = 'org.omg.xmi.namespace.UML'
50 xmlns:
common=
"http://exslt.org/common"
51 exclude-result-prefixes =
"xalan"
57 <xsl:key name=
"context-resource"
58 match=
"resource" use=
"@name"/>
60 <xsl:key name=
"tokenids" match=
"@tokenid|@sendtokenid" use=
"."/>
62 <xsl:key name=
"actions" match=
"/model/namespace/resource/action"
65 <xsl:key name=
"definename" match=
"//rng:define" use=
"@name"/>
67 <xsl:key name=
"resources" match=
"/model/namespace/resource" use=
"@resource"/>
69 <xsl:key name=
"value-with-content" match=
"//rng:value"
72 <xsl:key name=
"same-token-name" match=
"rng:element|rng:attribute" use=
"@localname"/>
74 <!-- license header -->
75 <xsl:template name=
"licenseheader">
79 THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT!
91 generates token identifer for a namespace
96 <xsl:template name=
"fastnamespace">
97 <xsl:if test=
"string-length(@prefix) > 0">
98 <xsl:text>NS_
</xsl:text>
99 <xsl:value-of select=
"@prefix"/>
105 generates local part of token identifier for a rng:define
107 OOXML_<rng:define/@localname>
110 <xsl:template name=
"fastlocalname">
111 <xsl:text>OOXML_
</xsl:text>
112 <xsl:value-of select=
"@localname"/>
117 generates identifier for a token
120 <xsl:template name=
"fasttoken">
121 <xsl:variable name=
"ns">
122 <xsl:call-template name=
"fastnamespace"/>
124 <xsl:if test=
"string-length($ns) > 0">
125 <xsl:value-of select=
"$ns"/>
126 <xsl:text>|
</xsl:text>
128 <xsl:call-template name=
"fastlocalname"/>
131 <!-- generates identifier for a namespace
136 <xsl:template name=
"idfornamespace">
137 <xsl:text>NN_
</xsl:text>
138 <xsl:value-of select=
"translate(@name, '-', '_')"/>
141 <!-- generates local part of identier for rng:define
143 DEFINE_<rng:define/@name>
146 <xsl:template name=
"localidfordefine">
147 <xsl:text>DEFINE_
</xsl:text>
148 <xsl:value-of select=
"@name"/>
151 <!-- generates id for a rng:define
153 NN_<namespace/@name> | DEFINE_<rng:define/@name>
156 <xsl:template name=
"idfordefine">
157 <xsl:for-each select=
"ancestor::namespace">
158 <xsl:call-template name=
"idfornamespace"/>
160 <xsl:text>|
</xsl:text>
161 <xsl:call-template name=
"localidfordefine"/>
166 creates case label for a rng:define:
168 case NN_<namesapce/@name> | DEFINE_<rng:define/@name>:
171 <xsl:template name=
"caselabeldefine">
172 <xsl:text>case
</xsl:text>
173 <xsl:call-template name=
"idfordefine"/>
174 <xsl:text>:
</xsl:text>
178 Generates name for a value string.
180 Value strings are possible values for attributes in OOXML.
182 @param string the string as present in the according <rng:value>
184 <xsl:template name=
"valuestringname">
185 <xsl:param name=
"string"/>
186 <xsl:text>OOXMLValueString_
</xsl:text>
187 <xsl:value-of select=
"translate($string, '-+ ,', 'mp__')"/>
191 Generates qname for id.
193 @param id the id to generate qname for
195 If id is of format <prefix>:<localname> the result is
197 NS_<prefix>::LN_<localname>
199 If id does not contain ":" the result is just id.
201 <xsl:template name='idtoqname'
>
202 <xsl:param name='id'
/>
204 <xsl:when test=
"contains($id, ':')">
205 <xsl:text>NS_
</xsl:text>
206 <xsl:value-of select='substring-before($id,
":")'
/>
207 <xsl:text>::LN_
</xsl:text>
208 <xsl:value-of select='substring-after($id,
":")'
/>
211 <xsl:value-of select=
"$id"/>
217 Returns the identifier for a namespace.
219 NS_<namespace/@alias>
222 <xsl:template name=
"namespaceid">
223 <xsl:text>NS_
</xsl:text>
224 <xsl:value-of select=
"@alias"/>
228 Returns the value of the @resource attribute of the <resource>
229 node according to the current <define>.
231 <xsl:template name=
"contextresource">
232 <xsl:variable name=
"name" select=
"@name"/>
233 <xsl:variable name=
"nsid" select=
"generate-id(ancestor::namespace)"/>
234 <xsl:variable name=
"resourcesamens">
235 <xsl:for-each select=
"key('context-resource', @name)">
236 <xsl:if test=
"generate-id(ancestor::namespace) = $nsid">
237 <xsl:value-of select=
"@resource"/>
242 <xsl:when test=
"$name='BUILT_IN_ANY_TYPE'">
243 <xsl:text>Any
</xsl:text>
245 <xsl:when test=
"string-length($resourcesamens) = 0">
246 <xsl:for-each select=
"key('context-resource', @name)[1]">
247 <xsl:value-of select=
"@resource"/>
251 <xsl:value-of select=
"$resourcesamens"/>
256 <xsl:template name=
"idforref">
257 <xsl:variable name=
"name" select=
"@name"/>
258 <xsl:variable name=
"result1">
259 <xsl:for-each select=
"ancestor::namespace/rng:grammar/rng:define[@name=$name]">
260 <xsl:call-template name=
"idfordefine"/>
264 <xsl:when test=
"$name='BUILT_IN_ANY_TYPE'">
265 <xsl:text>0</xsl:text>
267 <xsl:when test=
"string-length($result1) = 0">
268 <xsl:for-each select=
"(ancestor::model/namespace/rng:grammar/rng:define[@name=$name])[1]">
269 <xsl:call-template name=
"idfordefine"/>
273 <xsl:value-of select=
"$result1"/>
278 <!-- factoryclassname -->
279 <xsl:template name=
"factoryclassname">
280 <xsl:text>OOXMLFactory_
</xsl:text>
281 <xsl:value-of select=
"translate(@name, '-', '_')"/>
284 <xsl:template name=
"factoryincludes">
285 <xsl:for-each select=
"/model/namespace">
287 #include
"OOXMLFactory_</xsl:text>
288 <xsl:value-of select="@name
"/>
289 <xsl:text>.hxx"</xsl:text>
293 <xsl:template name=
"factorydefineiddecls">
294 <xsl:for-each select=
"//rng:define">
295 <xsl:sort select=
"@name"/>
296 <xsl:if test=
"generate-id(key('definename', @name)[1]) = generate-id(.)">
298 extern const Id
</xsl:text>
299 <xsl:call-template name=
"localidfordefine"/>
300 <xsl:text>;
</xsl:text>
305 <xsl:template name=
"factorydefineidimpls">
306 <xsl:for-each select=
"//rng:define">
307 <xsl:sort select=
"@name"/>
308 <xsl:if test=
"generate-id(key('definename', @name)[1]) = generate-id(.)">
311 <xsl:call-template name=
"localidfordefine"/>
312 <xsl:text> =
</xsl:text>
313 <xsl:value-of select=
"position()"/>
314 <xsl:text>;
</xsl:text>
319 <xsl:template name=
"resources">
320 <xsl:for-each select=
"/model/namespace/resource">
321 <xsl:if test=
"generate-id(key('resources', @resource)[1])=generate-id(.)">
322 <xsl:text>RT_
</xsl:text>
323 <xsl:value-of select=
"@resource"/>
324 <xsl:text>,

</xsl:text>