xref: /AOO41X/main/xmerge/source/htmlsoff/sofftohtml.xsl (revision 54628ca40d27d15cc98fe861da7fff7e60c2f7d6)
1<?xml version="1.0" encoding="UTF-8"?>
2<!--***********************************************************
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements.  See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership.  The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License.  You may obtain a copy of the License at
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied.  See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 *
21 ***********************************************************-->
22
23
24<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:style="http://openoffice.org/2000/style" xmlns:table="http://openoffice.org/2000/table" xmlns:text="http://openoffice.org/2000/text" xmlns:office="http://openoffice.org/2000/office" xmlns:fo="http://www.w3.org/1999/XSL/Format">
25    <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" encoding="ISO-8859-1"/>
26    <!--doctype-system=[<!ENTITY acirc "">] -->
27    <xsl:strip-space elements="tokens"/>
28    <xsl:template match="office:document">
29        <html>
30            <xsl:apply-templates/>
31        </html>
32    </xsl:template>
33    <xsl:template match="office:document-content">
34        <html>
35            <xsl:apply-templates/>
36        </html>
37    </xsl:template>
38    <xsl:template match="office:automatic-styles">
39        <style type="text/css">p.Table-Heading{font-weight:bold;}<xsl:apply-templates/>
40        </style>
41    </xsl:template>
42    <xsl:template match="office:styles"/>
43    <xsl:template match="office:meta"/>
44    <xsl:template match="office:settings"/>
45    <xsl:template match="style:style">
46        <xsl:if test="@style:family ='paragraph'">p.<xsl:value-of select="@style:name"/>{<xsl:apply-templates/>}</xsl:if>
47        <xsl:if test="@style:family ='paragraph'">p.<xsl:value-of select="@style:name"/>{<xsl:if test="@style:parent-style-name='Table Heading'">font-weight:bold;font-style:italic;</xsl:if>
48            <xsl:apply-templates/>}</xsl:if>
49        <xsl:if test="@style:family ='table-cell'">td.<xsl:value-of select="@style:name"/>{<xsl:if test="@style:parent-style-name='Table Heading'">font-weight:bold;font-style:italic;</xsl:if>
50            <xsl:apply-templates/>}</xsl:if>
51    </xsl:template>
52    <xsl:template match="style:properties">
53        <!--<xsl:param name="style" select="@fo:font-weight"/>-->
54        <xsl:if test="@fo:font-weight">font-weight:<xsl:value-of select="@fo:font-weight"/>;</xsl:if>
55        <xsl:if test="@fo:font-style">font-style:<xsl:value-of select="@fo:font-style"/>;</xsl:if>
56        <xsl:if test="@style:font-name">font-family:<xsl:value-of select="@style:font-name"/>;</xsl:if>
57        <xsl:if test="@fo:font-size">font-size:<xsl:value-of select="@fo:font-size"/>;</xsl:if>
58        <xsl:if test="@style:text-underline='single'">text-decoration:underline;</xsl:if>
59        <xsl:if test="@style:text-crossing-out='single-line'">text-decoration:line-through;</xsl:if>
60        <xsl:if test="@fo:text-align='start'">text-align:left</xsl:if>
61        <xsl:if test="@fo:text-align='center'">text-align:center</xsl:if>
62        <xsl:if test="@fo:text-align='end'">text-align:right</xsl:if>
63        <!--<xsl:value-of select="$style"/>-->
64    </xsl:template>
65    <xsl:template match="office:body">
66        <xsl:apply-templates/>
67    </xsl:template>
68    <xsl:template match="table:table">
69        <table border="1" cellpadding="2" width="100%">
70            <xsl:apply-templates/>
71        </table>
72    </xsl:template>
73    <xsl:template match="table:table-header-rows">
74        <th>
75            <xsl:apply-templates/>
76        </th>
77    </xsl:template>
78    <xsl:template match="table:table-row">
79        <tr>
80            <xsl:apply-templates/>
81        </tr>
82    </xsl:template>
83    <xsl:template match="table:table-cell">
84        <xsl:text disable-output-escaping="yes">&lt;td class="</xsl:text>
85        <xsl:value-of select="@table:style-name"/>
86        <xsl:text disable-output-escaping="yes">"&gt;</xsl:text>
87        <!--<xsl:value-of select="."/>-->
88        <xsl:apply-templates/>
89        <xsl:text disable-output-escaping="yes">&lt;/td&gt;</xsl:text>
90        <!--<td width="20%">
91        <xsl:apply-templates />
92        </td>-->
93    </xsl:template>
94    <xsl:template match="text:p">
95        <xsl:if test="ancestor-or-self::table:table-cell">
96            <xsl:if test=".=''">
97                <br/>
98            </xsl:if>
99        </xsl:if>
100        <xsl:text disable-output-escaping="yes">&lt;p class="</xsl:text>
101        <xsl:choose>
102            <xsl:when test="@text:style-name ='Table Heading'">Table-Heading</xsl:when>
103            <xsl:otherwise>
104                <xsl:value-of select="@text:style-name"/>
105            </xsl:otherwise>
106        </xsl:choose>
107        <xsl:text disable-output-escaping="yes">"&gt;</xsl:text>
108        <xsl:apply-templates/>
109        <xsl:text disable-output-escaping="yes">&lt;/p&gt;</xsl:text>
110        <!--<xsl:value-of select="."/>-->
111        <!--<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>-->
112        <!--<br/>-->
113    </xsl:template>
114</xsl:stylesheet>
115