Update ooo320-m1
[ooovba.git] / writerfilter / source / doctok / WW8xmi.xsl
blob1cc7d77c8d4d26f0976815a3c1d61c2934f42ff7
1 <!--
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 $
12 $Revision: 1.4 $
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 ************************************************************************/
33 -->
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"/>
44 </UML:Class>
45 </xsl:template>
47 <xsl:template match="xhtml:table">
48 <xsl:apply-templates select="xhtml:tbody/xhtml:tr[2]"/>
49 </xsl:template>
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">
56 <xsl:choose>
57 <xsl:when test='contains(xhtml:td[4], "[")'>
58 <xsl:value-of select='substring-before(xhtml:td[4], "[")'/>
59 </xsl:when>
60 <xsl:otherwise>
61 <xsl:value-of select="xhtml:td[4]"/>
62 <xsl:variable name="stereotype">attribute</xsl:variable>
63 </xsl:otherwise>
64 </xsl:choose>
65 </xsl:variable>
66 <xsl:variable name='stereotype'>
67 <xsl:choose>
68 <xsl:when test='contains(xhtml:td[4], "[")'>array</xsl:when>
69 <xsl:otherwise>attribute</xsl:otherwise>
70 </xsl:choose>
71 </xsl:variable>
72 <xsl:variable name="saltype">
73 <xsl:choose>
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>
81 </xsl:choose>
82 </xsl:variable>
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>
89 <UML: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>
94 </UML:TaggedValue>
95 </UML:ModelElement.taggedValue>
96 <UML:ModelElement.taggedValue>
97 <UML: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>
102 </UML:TaggedValue>
103 </UML:ModelElement.taggedValue>
104 <UML:ModelElement.taggedValue>
105 <UML: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>
110 </UML:TaggedValue>
111 </UML:ModelElement.taggedValue>
112 <UML:ModelElement.taggedValue>
113 <UML: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>
118 </UML:TaggedValue>
119 </UML:ModelElement.taggedValue>
120 <UML:ModelElement.taggedValue>
121 <UML: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>
126 </UML:TaggedValue>
127 </UML:ModelElement.taggedValue>
128 <UML:ModelElement.taggedValue>
129 <UML: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>
134 </UML:TaggedValue>
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>
139 <UML: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>
144 </UML:TaggedValue>
145 </UML:ModelElement.taggedValue>
146 </xsl:if>
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>
153 </UML:Attribute>
154 </UML:Classifier.feature>
155 </xsl:template>
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>
162 </xsl:call-template>
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>
168 </xsl:template>
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"/>
176 </xsl:call-template>
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>
182 </xsl:template>
184 <xsl:template match="*">
185 <xsl:copy-of select="."/>
186 </xsl:template>
188 </xsl:stylesheet>