1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22<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#"
23  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">
24<xsl:output method="xml" indent="yes"/>
25
26<xsl:template match="/">
27  <out>
28    <xsl:for-each select="//xhtml:table">
29      <xsl:apply-templates select="." mode="eschertable"/>
30    </xsl:for-each>
31  </out>
32</xsl:template>
33
34<xsl:template match="xhtml:table" mode="eschertable">
35  <xsl:apply-templates select=".//xhtml:tr[position() > 1]" mode="eschertable"/>
36</xsl:template>
37
38<xsl:template match="xhtml:tr" mode="eschertable">
39  <xsl:variable name="name">
40    <xsl:value-of select=".//xhtml:td[1]"/>
41  </xsl:variable>
42  <UML:Class>
43    <xsl:attribute name="xmi.id">
44      <xsl:value-of select="$name"/>
45    </xsl:attribute>
46    <xsl:attribute name="name">
47      <xsl:value-of select="$name"/>
48    </xsl:attribute>
49    <UML:ModelElement.stereotype>
50      <UML:Stereotype xmi.idref="dffopt" />
51    </UML:ModelElement.stereotype>
52    <xsl:apply-templates select=".//xhtml:td[1]" mode="optname"/>
53    <xsl:apply-templates select=".//xhtml:td[2]" mode="fopid"/>
54    <xsl:apply-templates select=".//xhtml:td[3]" mode="type"/>
55    <xsl:apply-templates select=".//xhtml:td[4]" mode="default"/>
56    <xsl:apply-templates select=".//xhtml:td[5]" mode="comment"/>
57  </UML:Class>
58</xsl:template>
59
60<xsl:template match="xhtml:td" mode="optname">
61  <UML:ModelElement.taggedValue>
62    <UML:TaggedValue>
63      <UML:TaggedValue.dataValue>rtf:shp<xsl:value-of select="."/></UML:TaggedValue.dataValue>
64      <UML:TaggedValue.type>
65        <UML:TagDefinition xmi.idref="optname" />
66      </UML:TaggedValue.type>
67    </UML:TaggedValue>
68  </UML:ModelElement.taggedValue>
69</xsl:template>
70
71<xsl:template match="xhtml:td" mode="fopid">
72  <UML:ModelElement.taggedValue>
73    <UML:TaggedValue>
74      <UML:TaggedValue.dataValue><xsl:value-of select="."/></UML:TaggedValue.dataValue>
75      <UML:TaggedValue.type>
76        <UML:TagDefinition xmi.idref="fopid" />
77      </UML:TaggedValue.type>
78    </UML:TaggedValue>
79  </UML:ModelElement.taggedValue>
80</xsl:template>
81
82<xsl:template match="xhtml:td" mode="type">
83  <UML:ModelElement.taggedValue>
84    <UML:TaggedValue>
85      <UML:TaggedValue.dataValue>
86        <xsl:call-template name="saltype">
87          <xsl:with-param name="type" select="."/>
88        </xsl:call-template>
89      </UML:TaggedValue.dataValue>
90      <UML:TaggedValue.type>
91        <UML:TagDefinition xmi.idref="type" />
92      </UML:TaggedValue.type>
93    </UML:TaggedValue>
94  </UML:ModelElement.taggedValue>
95  <xsl:if test=".='BOOL'">
96    <UML:ModelElement.taggedValue>
97      <UML:TaggedValue>
98        <UML:TaggedValue.dataValue>1</UML:TaggedValue.dataValue>
99        <UML:TaggedValue.type>
100          <UML:TagDefinition xmi.idref="isbool" />
101        </UML:TaggedValue.type>
102      </UML:TaggedValue>
103    </UML:ModelElement.taggedValue>
104  </xsl:if>
105</xsl:template>
106
107<xsl:template match="xhtml:td" mode="default">
108  <UML:ModelElement.taggedValue>
109    <UML:TaggedValue>
110      <UML:TaggedValue.dataValue><xsl:value-of select="."/></UML:TaggedValue.dataValue>
111      <UML:TaggedValue.type>
112        <UML:TagDefinition xmi.idref="default" />
113      </UML:TaggedValue.type>
114    </UML:TaggedValue>
115  </UML:ModelElement.taggedValue>
116</xsl:template>
117
118<xsl:template match="xhtml:td" mode="comment">
119  <UML:ModelElement.taggedValue>
120    <UML:TaggedValue>
121      <UML:TaggedValue.dataValue><xsl:value-of select="."/></UML:TaggedValue.dataValue>
122      <UML:TaggedValue.type>
123        <UML:TagDefinition xmi.idref="comment" />
124      </UML:TaggedValue.type>
125    </UML:TaggedValue>
126  </UML:ModelElement.taggedValue>
127</xsl:template>
128
129<xsl:template name="saltype">
130  <xsl:param name="type"/>
131  <xsl:choose>
132    <xsl:when test="$type='LONG'">U32</xsl:when>
133    <xsl:when test="$type='BOOL'">U8</xsl:when>
134    <xsl:when test="$type='WCHAR*'">String</xsl:when>
135    <xsl:otherwise>unknown</xsl:otherwise>
136  </xsl:choose>
137</xsl:template>
138
139</xsl:stylesheet>
140