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:UML = 'org.omg.xmi.namespace.UML' xml:
space=
"default">
49 <xsl:output method=
"xml" />
51 <xsl:key name=
"namespace-aliases" match=
"//namespace-alias" use=
"@name"/>
53 <xsl:template match=
"/">
54 <xsl:apply-templates/>
57 <xsl:template name=
"prefixfromurl">
58 <xsl:param name=
"url"/>
59 <xsl:variable name=
"prefix" select=
"key('namespace-aliases', $url)/@alias"/>
61 <xsl:when test=
"string-length($prefix) > 0">
62 <xsl:value-of select=
"$prefix"/>
65 <xsl:value-of select=
"translate(substring-after($url, 'http://'), '/.', '__')"/>
70 <xsl:template name=
"prefixforgrammar">
71 <xsl:variable name=
"ns" select=
"ancestor::namespace/rng:grammar/@ns"/>
72 <xsl:variable name=
"prefix" select=
"key('namespace-aliases', $ns)/@alias"/>
74 <xsl:when test=
"string-length($prefix) > 0">
75 <xsl:value-of select=
"$prefix"/>
78 <xsl:call-template name=
"prefixfromurl">
79 <xsl:with-param name=
"url" select=
"$ns"/>
85 <xsl:template name=
"nsforgrammar">
86 <xsl:value-of select=
"ancestor::namespace/rng:grammar/@ns"/>
89 <xsl:template match=
"rng:element[@name|./rng:anyName] | rng:attribute[@name] | element | attribute">
90 <xsl:variable name=
"prefix">
92 <xsl:when test=
"contains(@name, ':')">
93 <xsl:variable name=
"myname" select=
"@name"/>
94 <xsl:call-template name=
"prefixfromurl">
95 <xsl:with-param name=
"url" select=
"string(namespace::*[local-name(.) = substring-before($myname, ':')])"/>
98 <xsl:when test=
"name(.)='attribute'">
99 <xsl:if test=
"ancestor::namespace/rng:grammar/@attributeFormDefault='qualified'">
100 <xsl:call-template name=
"prefixforgrammar"/>
104 <xsl:call-template name=
"prefixforgrammar"/>
108 <xsl:variable name=
"ns">
110 <xsl:when test=
"contains(@name, ':')">
111 <xsl:variable name=
"myname" select=
"@name"/>
112 <xsl:value-of select=
"string(namespace::*[local-name(.) = substring-before($myname, ':')])"/>
114 <xsl:when test=
"name(.)='attribute'">
115 <xsl:if test=
"ancestor::rng:grammar/@attributeFormDefault='qualified'">
116 <xsl:call-template name=
"nsforgrammar"/>
120 <xsl:call-template name=
"nsforgrammar"/>
124 <xsl:variable name=
"localname">
126 <xsl:when test=
"contains(@name, ':')">
127 <xsl:value-of select=
"substring-after(@name, ':')"/>
129 <xsl:when test=
"./rng:anyName">
130 <xsl:text>FAST_TOKENS_END
</xsl:text>
133 <xsl:value-of select=
"@name"/>
138 <xsl:apply-templates select=
"@*"/>
139 <xsl:attribute name=
"enumname">
140 <xsl:if test=
"string-length($prefix) > 0">
141 <xsl:value-of select=
"$prefix"/>
142 <xsl:text>:
</xsl:text>
144 <xsl:value-of select=
"$localname"/>
146 <xsl:attribute name=
"qname">
147 <xsl:if test=
"string-length($ns) > 0">
148 <xsl:value-of select=
"$ns"/>
149 <xsl:text>:
</xsl:text>
151 <xsl:value-of select=
"$localname"/>
153 <xsl:attribute name=
"prefix">
154 <xsl:value-of select=
"$prefix"/>
156 <xsl:attribute name=
"localname">
157 <xsl:value-of select=
"$localname"/>
159 <xsl:apply-templates/>
163 <xsl:template match=
"rng:grammar">
165 <xsl:apply-templates select=
"@*"/>
166 <xsl:attribute name=
"application">
167 <xsl:value-of select=
"substring-before(substring-after(@ns, 'http://schemas.openxmlformats.org/'), '/')"/>
169 <xsl:apply-templates/>
173 <xsl:template match=
"node()|@*">
175 <xsl:apply-templates select=
"@*"/>
176 <xsl:apply-templates/>
180 <xsl:template match=
"model">
182 <xsl:apply-templates select=
"@*"/>
183 <xsl:apply-templates/>
187 <xsl:template match=
"rng:define|rng:ref">
189 <xsl:apply-templates select=
"@*"/>
190 <xsl:attribute name=
"classfordefine">
191 <xsl:variable name=
"name" select=
"@name"/>
193 <xsl:when test=
"(starts-with(@name, 'CT_') or starts-with(@name, 'EG_') or starts-with(@name, 'AG_'))">1</xsl:when>
194 <xsl:when test=
"ancestor::namespace//start[@name=$name]">1</xsl:when>
195 <xsl:otherwise>0</xsl:otherwise>
198 <xsl:apply-templates/>
202 <xsl:template match=
"namespace">
203 <xsl:variable name=
"ns" select=
".//rng:grammar/@ns"/>
205 <xsl:apply-templates select=
"@*"/>
206 <xsl:attribute name=
"namespacealias">
207 <xsl:value-of select=
"key('namespace-aliases', $ns)/@alias"/>
209 <xsl:attribute name=
"prefix"><xsl:value-of select=
"translate(substring-after($ns, 'http://schemas.openxmlformats.org/'), '/-', '__')"/></xsl:attribute>
210 <xsl:apply-templates/>