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 .
18 <xsl:stylesheet version=
"1.0"
19 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
20 xmlns:UML = 'org.omg.xmi.namespace.UML'
22 <xsl:output method=
"xml"/>
24 <xsl:template match=
"/">
26 <xsl:apply-templates select=
"*"/>
30 <xsl:template name=
"calcsizeinner">
31 <xsl:param name=
"size">0</xsl:param>
32 <xsl:variable name=
"arraycount">
34 <xsl:when test=
"@array-count">
35 <xsl:value-of select=
"@array-count"/>
37 <xsl:otherwise>1</xsl:otherwise>
40 <xsl:variable name=
"mysize">
42 <xsl:when test=
"@size and not(@offset)">
43 <xsl:value-of select=
"number($arraycount) * number(@size)"/>
45 <xsl:otherwise>0</xsl:otherwise>
49 <xsl:when test=
"following-sibling::*">
50 <xsl:for-each select=
"following-sibling::*[1]">
51 <xsl:call-template name=
"calcsizeinner">
52 <xsl:with-param name=
"size"
53 select=
"number($size) + number($mysize)"/>
58 <xsl:value-of select=
"number($size) + number($mysize)"/>
63 <xsl:template name=
"calcsize">
64 <xsl:for-each select=
"*[1]">
65 <xsl:call-template name=
"calcsizeinner"/>
69 <xsl:template name=
"calcoffsetinner">
70 <xsl:variable name=
"arraycount">
72 <xsl:when test=
"@array-count">
73 <xsl:value-of select=
"@array-count"/>
75 <xsl:otherwise>1</xsl:otherwise>
78 <xsl:variable name=
"mysize">
80 <xsl:when test=
"@size and not(@offset)">
81 <xsl:value-of select=
"number($arraycount) * number(@size)"/>
83 <xsl:otherwise>0</xsl:otherwise>
87 <xsl:when test=
"preceding-sibling::*">
88 <xsl:variable name=
"precedingoffset">
89 <xsl:for-each select=
"preceding-sibling::*[1]">
90 <xsl:call-template name=
"calcoffsetinner"/>
93 <xsl:value-of select=
"number($precedingoffset) + number($mysize)"/>
96 <xsl:value-of select=
"$mysize"/>
101 <xsl:template name=
"calcoffset">
103 <xsl:when test=
"@offset">
104 <xsl:value-of select=
"@offset"/>
107 <xsl:for-each select=
"preceding-sibling::*[1]">
108 <xsl:call-template name=
"calcoffsetinner"/>
114 <xsl:template match=
"ww8resource">
116 <xsl:attribute name=
"xmi.id">
117 <xsl:value-of select=
"@name"/>
119 <xsl:attribute name=
"name">
120 <xsl:value-of select=
"@name"/>
122 <UML:ModelElement.stereotype
>
123 <UML:Stereotype xmi.
idref=
"ww8resource"/>
124 </UML:ModelElement.stereotype
>
125 <xsl:for-each select=
"stereotype">
126 <UML:ModelElement.stereotype
>
128 <xsl:attribute name=
"xmi.idref">
129 <xsl:value-of select=
"@name"/>
132 </UML:ModelElement.stereotype
>
134 <UML:ModelElement.taggedValue
>
136 <UML:TaggedValue.dataValue
>
137 <xsl:call-template name=
"calcsize"/>
138 </UML:TaggedValue.dataValue
>
139 <UML:TaggedValue.type
>
140 <UML:TagDefinition xmi.
idref=
"size"/>
141 </UML:TaggedValue.type
>
143 </UML:ModelElement.taggedValue
>
145 <xsl:apply-templates select=
"*"/>
148 <UML:Generalization isSpecification=
"false">
149 <xsl:attribute name=
"xmi.id">
150 <xsl:value-of select=
"@name"/>
151 <xsl:text>-
</xsl:text>
152 <xsl:value-of select=
"@resource"/>
154 <UML:Generalization.child
>
156 <xsl:attribute name=
"xmi.idref">
157 <xsl:value-of select=
"@name"/>
160 </UML:Generalization.child
>
161 <UML:Generalization.parent
>
162 <UML:Class xmi.
idref=
"Properties">
163 <xsl:attribute name=
"xmi.idref">
164 <xsl:value-of select=
"@resource"/>
167 </UML:Generalization.parent
>
168 </UML:Generalization>
171 <xsl:template match=
"sprm">
172 <xsl:variable name=
"isww8resource">
174 <xsl:when test=
"count(*) > 0">YES
</xsl:when>
175 <xsl:otherwise>NO
</xsl:otherwise>
179 <xsl:attribute name=
"xmi.id">
180 <xsl:value-of select=
"@name"/>
182 <xsl:attribute name=
"name">
183 <xsl:value-of select=
"@name"/>
185 <xsl:if test=
"$isww8resource='YES'">
186 <UML:ModelElement.stereotype
>
187 <UML:Stereotype xmi.
idref=
"ww8resource"/>
188 </UML:ModelElement.stereotype
>
190 <UML:ModelElement.stereotype
>
191 <UML:Stereotype xmi.
idref=
"ww8sprm"/>
192 </UML:ModelElement.stereotype
>
193 <xsl:call-template name=
"taggedvalue">
194 <xsl:with-param name=
"type">sprmcode
</xsl:with-param>
195 <xsl:with-param name=
"value" select=
"@code"/>
197 <xsl:call-template name=
"taggedvalue">
198 <xsl:with-param name=
"type">sprmid
</xsl:with-param>
199 <xsl:with-param name=
"value" select=
"@token"/>
201 <xsl:call-template name=
"taggedvalue">
202 <xsl:with-param name=
"type">kind
</xsl:with-param>
203 <xsl:with-param name=
"value" select=
"@kind"/>
205 <xsl:apply-templates select=
"*"/>
207 <xsl:if test=
"$isww8resource='YES'">
208 <xsl:call-template name=
"generalization">
209 <xsl:with-param name=
"parent">Properties
</xsl:with-param>
210 <xsl:with-param name=
"child" select=
"@name"/>
215 <xsl:template name=
"generalization">
216 <xsl:param name=
"parent"/>
217 <xsl:param name=
"child"/>
218 <UML:Generalization isSpecification=
"false">
219 <xsl:attribute name=
"xmi.id">
220 <xsl:value-of select=
"$child"/>
221 <xsl:text>-
</xsl:text>
222 <xsl:value-of select=
"$parent"/>
224 <UML:Generalization.child
>
226 <xsl:attribute name=
"xmi.idref">
227 <xsl:value-of select=
"$child"/>
230 </UML:Generalization.child
>
231 <UML:Generalization.parent
>
232 <UML:Class xmi.
idref=
"Properties">
233 <xsl:attribute name=
"xmi.idref">
234 <xsl:value-of select=
"$parent"/>
237 </UML:Generalization.parent
>
238 </UML:Generalization>
241 <xsl:template name=
"taggedvalue">
242 <xsl:param name=
"type"/>
243 <xsl:param name=
"value"/>
244 <UML:ModelElement.taggedValue
>
246 <UML:TaggedValue.dataValue
>
247 <xsl:value-of select=
"$value"/>
248 </UML:TaggedValue.dataValue
>
249 <UML:TaggedValue.type
>
251 <xsl:attribute name=
"xmi.idref">
252 <xsl:value-of select=
"$type"/>
255 </UML:TaggedValue.type
>
257 </UML:ModelElement.taggedValue
>
260 <xsl:template match=
"attribute">
261 <UML:Classifier.feature
>
263 <xsl:attribute name=
"name">
264 <xsl:value-of select=
"@name"/>
266 <xsl:call-template name=
"taggedvalue">
267 <xsl:with-param name=
"type">comment
</xsl:with-param>
268 <xsl:with-param name=
"value"/>
270 <xsl:call-template name=
"taggedvalue">
271 <xsl:with-param name=
"type">offset
</xsl:with-param>
272 <xsl:with-param name=
"value">
273 <xsl:call-template name=
"calcoffset"/>
276 <xsl:call-template name=
"taggedvalue">
277 <xsl:with-param name=
"type">shift
</xsl:with-param>
278 <xsl:with-param name=
"value"></xsl:with-param>
280 <xsl:call-template name=
"taggedvalue">
281 <xsl:with-param name=
"type">mask
</xsl:with-param>
282 <xsl:with-param name=
"value"></xsl:with-param>
284 <xsl:call-template name=
"taggedvalue">
285 <xsl:with-param name=
"type">bits
</xsl:with-param>
286 <xsl:with-param name=
"value"></xsl:with-param>
288 <xsl:call-template name=
"taggedvalue">
289 <xsl:with-param name=
"type">attrid
</xsl:with-param>
290 <xsl:with-param name=
"value">
292 <xsl:when test=
"@token">
293 <xsl:value-of select=
"@token"/>
296 <xsl:text>rtf:
</xsl:text>
297 <xsl:value-of select=
"@name"/>
302 <xsl:if test=
"@array-count">
303 <xsl:call-template name=
"taggedvalue">
304 <xsl:with-param name=
"type">arraycount
</xsl:with-param>
305 <xsl:with-param name=
"value">
306 <xsl:value-of select=
"@array-count"/>
310 <UML:StructuralFeature.type
>
312 <xsl:attribute name=
"xmi.idref">
313 <xsl:value-of select=
"@type"/>
316 </UML:StructuralFeature.type
>
318 <xsl:when test=
"@array-count">
319 <UML:ModelElement.stereotype
>
320 <UML:Stereotype xmi.
idref=
"array"/>
321 </UML:ModelElement.stereotype
>
324 <UML:ModelElement.stereotype
>
325 <UML:Stereotype xmi.
idref=
"attribute"/>
326 </UML:ModelElement.stereotype
>
330 </UML:Classifier.feature
>
333 <xsl:template match=
"bitfield">
334 <xsl:variable name=
"offset">
335 <xsl:call-template name=
"calcoffset"/>
337 <xsl:for-each select=
"bits">
338 <xsl:call-template name=
"bits">
339 <xsl:with-param name=
"offset" select=
"$offset"/>
344 <xsl:template name=
"mask">
345 <xsl:param name=
"count"/>
346 <xsl:param name=
"value"/>
349 <xsl:when test=
"number($count) = 1">
350 <xsl:value-of select=
"$value"/>
353 <xsl:call-template name=
"mask">
354 <xsl:with-param name=
"count" select=
"number($count) - 1"/>
355 <xsl:with-param name=
"value" select=
"number($value) * 2 + 1"/>
361 <xsl:template name=
"shift">
362 <xsl:param name=
"shift"/>
363 <xsl:param name=
"value"/>
366 <xsl:when test=
"number($shift) = 0">
367 <xsl:value-of select=
"$value"/>
370 <xsl:call-template name=
"shift">
371 <xsl:with-param name=
"shift" select=
"number($shift) - 1"/>
372 <xsl:with-param name=
"value" select=
"$value * 2"/>
378 <xsl:template name='dectohex'
>
379 <xsl:param name=
"number"/>
380 <xsl:if test=
"$number > 16">
381 <xsl:call-template name=
"dectohex">
382 <xsl:with-param name=
"number" select=
"floor($number div 16)"/>
385 <xsl:value-of select=
"substring('0123456789abcdef', $number mod 16 + 1, 1)"/>
388 <xsl:template name=
"calcshift">
390 <xsl:when test=
"@shift">
391 <xsl:value-of select=
"@shift"/>
394 <xsl:value-of select=
"sum(following-sibling::*[not (@shift)]/@bits)"/>
399 <xsl:template name=
"bits">
400 <xsl:param name=
"offset"/>
401 <xsl:variable name=
"shift">
402 <xsl:call-template name=
"calcshift"/>
404 <xsl:variable name=
"mask">
405 <xsl:call-template name=
"mask">
406 <xsl:with-param name=
"count" select=
"@bits"/>
407 <xsl:with-param name=
"value" select=
"1"/>
410 <xsl:variable name=
"maskshifted">
411 <xsl:call-template name=
"shift">
412 <xsl:with-param name=
"shift" select=
"$shift"/>
413 <xsl:with-param name=
"value" select=
"$mask"/>
416 <xsl:variable name=
"maskhex">
417 <xsl:text>0x
</xsl:text>
418 <xsl:call-template name=
"dectohex">
419 <xsl:with-param name=
"number" select=
"$maskshifted"/>
422 <UML:Classifier.feature
>
424 <xsl:attribute name=
"name">
425 <xsl:value-of select=
"@name"/>
427 <UML:ModelElement.taggedValue
>
429 <UML:TaggedValue.dataValue
/>
430 <UML:TaggedValue.type
>
431 <UML:TagDefinition xmi.
idref=
"comment"/>
432 </UML:TaggedValue.type
>
434 </UML:ModelElement.taggedValue
>
435 <UML:ModelElement.taggedValue
>
437 <UML:TaggedValue.dataValue
>
438 <xsl:value-of select=
"$offset"/>
439 </UML:TaggedValue.dataValue
>
440 <UML:TaggedValue.type
>
441 <UML:TagDefinition xmi.
idref=
"offset"/>
442 </UML:TaggedValue.type
>
444 </UML:ModelElement.taggedValue
>
445 <UML:ModelElement.taggedValue
>
447 <UML:TaggedValue.dataValue
>
448 <xsl:value-of select=
"$shift"/>
449 </UML:TaggedValue.dataValue
>
450 <UML:TaggedValue.type
>
451 <UML:TagDefinition xmi.
idref=
"shift"/>
452 </UML:TaggedValue.type
>
454 </UML:ModelElement.taggedValue
>
455 <UML:ModelElement.taggedValue
>
457 <UML:TaggedValue.dataValue
>
458 <xsl:value-of select=
"$maskhex"/>
459 </UML:TaggedValue.dataValue
>
460 <UML:TaggedValue.type
>
461 <UML:TagDefinition xmi.
idref=
"mask"/>
462 </UML:TaggedValue.type
>
464 </UML:ModelElement.taggedValue
>
465 <UML:ModelElement.taggedValue
>
467 <UML:TaggedValue.dataValue
>
468 <xsl:value-of select=
"@bits"/>
469 </UML:TaggedValue.dataValue
>
470 <UML:TaggedValue.type
>
471 <UML:TagDefinition xmi.
idref=
"bits"/>
472 </UML:TaggedValue.type
>
474 </UML:ModelElement.taggedValue
>
475 <UML:ModelElement.taggedValue
>
477 <UML:TaggedValue.dataValue
>
479 <xsl:when test=
"@token">
480 <xsl:value-of select=
"@token"/>
483 <xsl:text>rtf:
</xsl:text>
484 <xsl:value-of select=
"@name"/>
487 </UML:TaggedValue.dataValue
>
488 <UML:TaggedValue.type
>
489 <UML:TagDefinition xmi.
idref=
"attrid"/>
490 </UML:TaggedValue.type
>
492 </UML:ModelElement.taggedValue
>
493 <UML:StructuralFeature.type
>
495 <xsl:attribute name=
"xmi.idref">
496 <xsl:value-of select=
"ancestor::bitfield/@type"/>
499 </UML:StructuralFeature.type
>
500 <UML:ModelElement.stereotype
>
501 <UML:Stereotype xmi.
idref=
"attribute"/>
502 </UML:ModelElement.stereotype
>
504 </UML:Classifier.feature
>
507 <xsl:template match=
"operation">
508 <UML:Classifier.feature
>
510 <xsl:attribute name=
"name">
511 <xsl:value-of select=
"@name"/>
513 <xsl:call-template name=
"taggedvalue">
514 <xsl:with-param name=
"type">opid
</xsl:with-param>
515 <xsl:with-param name=
"value">
517 <xsl:when test=
"@token">
518 <xsl:value-of select=
"@token"/>
521 <xsl:text>rtf:
</xsl:text>
522 <xsl:value-of select=
"@name"/>
527 <xsl:if test=
"@array-count">
528 <xsl:call-template name=
"taggedvalue">
529 <xsl:with-param name=
"type">arraycount
</xsl:with-param>
530 <xsl:with-param name=
"value">
531 <xsl:value-of select=
"@array-count"/>
535 <UML:BehavioralFeature.parameter
>
536 <UML:Parameter kind=
"return" name=
"return">
539 <xsl:attribute name=
"xmi.idref">
540 <xsl:value-of select=
"@type"/>
543 </UML:Parameter.type
>
545 </UML:BehavioralFeature.parameter
>
547 <xsl:when test=
"@array-count or stereotype[text()='array']">
548 <UML:ModelElement.stereotype
>
549 <UML:Stereotype xmi.
idref=
"array"/>
550 </UML:ModelElement.stereotype
>
553 <UML:ModelElement.stereotype
>
554 <UML:Stereotype xmi.
idref=
"attribute"/>
555 </UML:ModelElement.stereotype
>
559 </UML:Classifier.feature
>