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: WW8xmi.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 ************************************************************************/
34 <xsl:stylesheet version=
"1.0" xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform" xmlns:
office=
"urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:
style=
"urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:
text=
"urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:
table=
"urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:
draw=
"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:
fo=
"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:
xlink=
"http://www.w3.org/1999/xlink" xmlns:
dc=
"http://purl.org/dc/elements/1.1/" xmlns:
meta=
"urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:
number=
"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:
svg=
"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:
chart=
"urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:
dr3d=
"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:
math=
"http://www.w3.org/1998/Math/MathML" xmlns:
form=
"urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:
script=
"urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:
config=
"urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:
ooo=
"http://openoffice.org/2004/office" xmlns:
ooow=
"http://openoffice.org/2004/writer" xmlns:
oooc=
"http://openoffice.org/2004/calc" xmlns:
dom=
"http://www.w3.org/2001/xml-events" xmlns:
xforms=
"http://www.w3.org/2002/xforms" xmlns:
xsd=
"http://www.w3.org/2001/XMLSchema" xmlns:
xsi=
"http://www.w3.org/2001/XMLSchema-instance" xmlns:
rdf=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
35 xmlns:
rdfs=
"http://www.w3.org/2000/01/rdf-schema#" xmlns:UML = 'org.omg.xmi.namespace.UML' xml:
space=
"default" xmlns:
xhtml=
"http://www.w3.org/1999/xhtml">
36 <xsl:output method=
"xml" indent=
"yes"/>
38 <xsl:template match=
"/">
39 <UML:Class xmi.
id=
"dummy" name=
"dummy">
40 <UML:ModelElement.stereotype
>
41 <UML:Stereotype xmi.idref='access'
/>
42 </UML:ModelElement.stereotype
>
43 <xsl:apply-templates select=
"//xhtml:body/xhtml:table"/>
47 <xsl:template match=
"xhtml:table">
48 <xsl:apply-templates select=
"xhtml:tbody/xhtml:tr[2]"/>
51 <xsl:template name=
"handleTR">
52 <xsl:param name=
"offset"/>
53 <xsl:param name=
"shift"/>
54 <xsl:variable name=
"name"><xsl:value-of select=
"xhtml:td[3]"/></xsl:variable>
55 <xsl:variable name=
"type">
57 <xsl:when test='contains(xhtml:td[
4],
"[")'
>
58 <xsl:value-of select='substring-before(xhtml:td[
4],
"[")'
/>
61 <xsl:value-of select=
"xhtml:td[4]"/>
62 <xsl:variable name=
"stereotype">attribute
</xsl:variable>
66 <xsl:variable name='stereotype'
>
68 <xsl:when test='contains(xhtml:td[
4],
"[")'
>array
</xsl:when>
69 <xsl:otherwise>attribute
</xsl:otherwise>
72 <xsl:variable name=
"saltype">
74 <xsl:when test=
"$type='U8'">sal_uInt8
</xsl:when>
75 <xsl:when test=
"$type='S8'">sal_Int8
</xsl:when>
76 <xsl:when test=
"$type='U16'">sal_uInt16
</xsl:when>
77 <xsl:when test=
"$type='S16'">sal_Int16
</xsl:when>
78 <xsl:when test=
"$type='U32'">sal_uInt32
</xsl:when>
79 <xsl:when test=
"$type='S32'">sal_Int32
</xsl:when>
80 <xsl:otherwise>void *
</xsl:otherwise>
83 <xsl:variable name=
"bits"><xsl:value-of select=
"xhtml:td[5]"/></xsl:variable>
84 <xsl:variable name=
"mask"><xsl:value-of select=
"xhtml:td[6]"/></xsl:variable>
85 <xsl:variable name=
"comment"><xsl:value-of select=
"xhtml:td[7]"/></xsl:variable>
86 <UML:Classifier.feature
>
87 <UML:Attribute><xsl:attribute name=
"name"><xsl:value-of select=
"$name"/></xsl:attribute>
88 <UML:ModelElement.taggedValue
>
90 <UML:TaggedValue.dataValue
><xsl:value-of select=
"$comment"/></UML:TaggedValue.dataValue
>
91 <UML:TaggedValue.type
>
92 <UML:TagDefinition xmi.idref = 'comment'
/>
93 </UML:TaggedValue.type
>
95 </UML:ModelElement.taggedValue
>
96 <UML:ModelElement.taggedValue
>
98 <UML:TaggedValue.dataValue
><xsl:value-of select=
"$offset"/></UML:TaggedValue.dataValue
>
99 <UML:TaggedValue.type
>
100 <UML:TagDefinition xmi.idref = 'offset'
/>
101 </UML:TaggedValue.type
>
103 </UML:ModelElement.taggedValue
>
104 <UML:ModelElement.taggedValue
>
106 <UML:TaggedValue.dataValue
><xsl:value-of select=
"$shift"/></UML:TaggedValue.dataValue
>
107 <UML:TaggedValue.type
>
108 <UML:TagDefinition xmi.idref = 'shift'
/>
109 </UML:TaggedValue.type
>
111 </UML:ModelElement.taggedValue
>
112 <UML:ModelElement.taggedValue
>
114 <UML:TaggedValue.dataValue
><xsl:value-of select=
"$mask"/></UML:TaggedValue.dataValue
>
115 <UML:TaggedValue.type
>
116 <UML:TagDefinition xmi.idref = 'mask'
/>
117 </UML:TaggedValue.type
>
119 </UML:ModelElement.taggedValue
>
120 <UML:ModelElement.taggedValue
>
122 <UML:TaggedValue.dataValue
><xsl:value-of select=
"$bits"/></UML:TaggedValue.dataValue
>
123 <UML:TaggedValue.type
>
124 <UML:TagDefinition xmi.idref = 'bits'
/>
125 </UML:TaggedValue.type
>
127 </UML:ModelElement.taggedValue
>
128 <UML:ModelElement.taggedValue
>
130 <UML:TaggedValue.dataValue
>rtf:
<xsl:value-of select='translate($name,
"abcdefghijklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ")'
/></UML:TaggedValue.dataValue
>
131 <UML:TaggedValue.type
>
132 <UML:TagDefinition xmi.idref = 'attrid'
/>
133 </UML:TaggedValue.type
>
135 </UML:ModelElement.taggedValue
>
136 <xsl:if test='$stereotype =
"array"'
>
137 <xsl:variable name='arraycount'
><xsl:value-of select='substring-before(substring-after(xhtml:td[
4],
"["),
"]")'
/></xsl:variable>
138 <UML:ModelElement.taggedValue
>
140 <UML:TaggedValue.dataValue
><xsl:value-of select=
"$arraycount"/></UML:TaggedValue.dataValue
>
141 <UML:TaggedValue.type
>
142 <UML:TagDefinition xmi.idref = 'arraycount'
/>
143 </UML:TaggedValue.type
>
145 </UML:ModelElement.taggedValue
>
147 <UML:StructuralFeature.type
>
148 <UML:DataType><xsl:attribute name=
"xmi.idref"><xsl:value-of select=
"$type"/></xsl:attribute></UML:DataType>
149 </UML:StructuralFeature.type
>
150 <UML:ModelElement.stereotype
>
151 <UML:Stereotype><xsl:attribute name=
"xmi.idref"><xsl:value-of select=
"$stereotype"/></xsl:attribute></UML:Stereotype>
152 </UML:ModelElement.stereotype
>
154 </UML:Classifier.feature
>
157 <xsl:template match=
"xhtml:tr[./xhtml:td[position()=1]/text()]">
158 <xsl:variable name=
"offset"><xsl:value-of select=
"xhtml:td[2]"/></xsl:variable>
159 <xsl:call-template name=
"handleTR">
160 <xsl:with-param name=
"offset" select=
"$offset"/>
161 <xsl:with-param name=
"shift">0</xsl:with-param>
163 <xsl:variable name=
"shift1"><xsl:value-of select=
"substring-after(xhtml:td[5], ':')"/></xsl:variable>
164 <xsl:apply-templates select=
"following-sibling::xhtml:tr[position()=1]">
165 <xsl:with-param name=
"offset" select=
"$offset"/>
166 <xsl:with-param name=
"shift" select=
"$shift1"/>
167 </xsl:apply-templates>
170 <xsl:template match=
"xhtml:tr[not(./xhtml:td[position()=1]/text())]">
171 <xsl:param name=
"offset"/>
172 <xsl:param name=
"shift"/>
173 <xsl:call-template name=
"handleTR">
174 <xsl:with-param name=
"offset" select=
"$offset"/>
175 <xsl:with-param name=
"shift" select=
"$shift"/>
177 <xsl:variable name=
"shift1"><xsl:value-of select=
"$shift+substring-after(xhtml:td[5], ':')"/></xsl:variable>
178 <xsl:apply-templates select=
"following-sibling::xhtml:tr[position()=1]">
179 <xsl:with-param name=
"offset" select=
"$offset"/>
180 <xsl:with-param name=
"shift" select=
"$shift1"/>
181 </xsl:apply-templates>
184 <xsl:template match=
"*">
185 <xsl:copy-of select=
"."/>