1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 *   Licensed to the Apache Software Foundation (ASF) under one or more
12 *   contributor license agreements. See the NOTICE file distributed
13 *   with this work for additional information regarding copyright
14 *   ownership. The ASF licenses this file to you under the Apache
15 *   License, Version 2.0 (the "License"); you may not use this file
16 *   except in compliance with the License. You may obtain a copy of
17 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18-->
19<!--
20    For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
21-->
22<xsl:stylesheet version="1.0"
23    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
24    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
25    xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
26    xmlns:dc="http://purl.org/dc/elements/1.1/"
27    xmlns:dom="http://www.w3.org/2001/xml-events"
28    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
29    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
30    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
31    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
32    xmlns:math="http://www.w3.org/1998/Math/MathML"
33    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
34    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
35    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
36    xmlns:ooo="http://openoffice.org/2004/office"
37    xmlns:oooc="http://openoffice.org/2004/calc"
38    xmlns:ooow="http://openoffice.org/2004/writer"
39    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
40    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
41    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
42    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
43    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
44    xmlns:xforms="http://www.w3.org/2002/xforms"
45    xmlns:xlink="http://www.w3.org/1999/xlink"
46    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
47    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
48    exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xforms xlink xsd xsi xforms xsd xsi"
49    xmlns="http://www.w3.org/1999/xhtml">
50
51
52    <!--+++++ INCLUDED XSL MODULES +++++-->
53
54    <!-- inheritance of office style properties is resolved into absolute styles. Office properties gathered as elements -->
55    <xsl:include href="../common/styles/style_collector.xsl" />
56
57    <!-- mapping rules of office style properties to CSS/HTML properties -->
58    <xsl:include href="../common/styles/style_mapping_css.xsl" />
59
60    <!-- office header element handling especially for XHTML -->
61    <xsl:include href="header.xsl" />
62
63    <!-- office body element handling especially for XHTML -->
64    <xsl:include href="body.xsl" />
65
66
67    <xsl:output method               = "xml"
68                encoding             = "UTF-8"
69                media-type           = "application/xhtml+xml"
70                indent               = "no"
71                omit-xml-declaration = "no"
72                doctype-public       = "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
73                doctype-system       = "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd" />
74
75
76
77    <xsl:variable name="namespace" select="'http://www.w3.org/1999/xhtml'" />
78
79    <!--+++++ PARAMETER SECTION +++++-->
80
81    <!-- OPTIONAL: if the document content is provided in a directory structure. Opposite to a single flat XML stream -->
82    <xsl:param name="isPackageFormat" />
83
84    <!-- OPTIONAL: (MANDATORY: for all input document with relative external links): parameter is an absolute file URL to the target directory.
85         Relative links from the office document (e.g. to external graphics) will get this parameter as a prefix -->
86    <xsl:param name="targetBaseURL" select="'./'" />
87
88    <!-- OPTIONAL: (MANDATORY: for all input document with content table) : parameter is an absolute file URL to the target document.
89         Relative links to this office document (e.g. to internal anchor) will get this parameter as a prefix -->
90    <xsl:param name="targetURL" select="'./'" />
91
92    <!-- OPTIONAL: (MANDATORY: for input document with relative internal links)
93         To access contents of an office file (content like the meta.xml, styles.xml file or  graphics) a URL could be chosen.
94     This could be even a JAR URL. The sourceBase of the content URL "jar:file:/C:/temp/Test.sxw!/content.xml" would be
95     "jar:file:/C:/temp/Test.sxw!/" for example.
96         When working with OpenOffice API a Package-URL encoded over HTTP can be used to access the jared contents of the jared document. -->
97    <xsl:param name="sourceBaseURL" select="'./'" />
98
99    <!-- OPTIONAL: (MANDATORY: for session management by URL rewriting)
100         Useful for WebApplications: if a HTTP session is not cookie based, URL rewriting is being used (the session is appended to the URL).
101         This URL session is used for example when links to graphics are created by XSLT. Otherwise the user have to log again in for every graphic he likes to see. -->
102    <xsl:param name="optionalURLSuffix" />
103
104    <!-- OPTIONAL: URL to office meta file (flat xml use the URL to the input file) -->
105    <xsl:param name="metaFileURL" />
106
107    <!-- OPTIONAL: URL to office meta file (flat xml use the URL to the input file) -->
108    <xsl:param name="stylesFileURL" />
109
110    <!-- OPTIONAL: DPI (dots per inch) the standard resolution of given pictures (necessary for the conversion of 'cm' into 'pixel')-->
111    <!-- Although many pictures have a 96 dpi resolution, a higher resolution give better results for common browsers -->
112    <!-- Cp. measure_conversion.xsl:
113         <xsl:param name="dpi" select="111" /> -->
114
115
116    <!-- OPTIONAL: in case of using a different processor than a JAVA XSLT, you can unable the Java functionality
117         (e.g. encoding chapter names for the content-table as href and anchors ) -->
118    <xsl:param name="java"        select="true()" />
119    <xsl:param name="javaEnabled" select="boolean($java)" />
120
121    <!-- OPTIONAL: for activating the debug mode set the variable here to 'true()' or give any value from outside -->
122    <xsl:param name="debug"                    select="false()" />
123    <xsl:param name="debugEnabled"             select="boolean($debug)" />
124    <xsl:param name="onlyStyleOutput"          select="false()" />
125    <xsl:param name="onlyStyleOutputEnabled"   select="boolean($onlyStyleOutput)" />
126
127    <!-- *************************************** -->
128    <!-- *** build the appropriate HTML file *** -->
129    <!-- *************************************** -->
130    <xsl:template match="/">
131        <!-- debug output of parameter value set -->
132        <xsl:if test="$debugEnabled">
133            <xsl:call-template name="debug-check-parameter" />
134        </xsl:if>
135        <xsl:message>XSL Vendor: '<xsl:value-of select="system-property('xsl:vendor')"/>'</xsl:message>
136        <!-- gathers style properties and
137            returns them as globalData parameter to the 'start-main' template            -->
138        <xsl:call-template name="collect-global-odf-properties" />
139    </xsl:template>
140
141
142    <!-- *************************** -->
143    <!-- *** Built up XHTML file *** -->
144    <!-- *************************** -->
145    <xsl:template name="start-main">
146        <xsl:param name="globalData" />
147
148        <xsl:variable name="lang">
149             <xsl:choose>
150                 <xsl:when test="$globalData/meta-file/*/office:meta/dc:language">
151                     <xsl:value-of select="$globalData/meta-file/*/office:meta/dc:language" />
152                 </xsl:when>
153                 <xsl:otherwise>en-US</xsl:otherwise>
154             </xsl:choose>
155        </xsl:variable>
156
157        <xsl:element name="html">
158
159            <xsl:attribute name="lang"><xsl:value-of select="$lang"/></xsl:attribute>
160            <xsl:comment>This file was converted to xhtml by LibreOffice - see https://cgit.freedesktop.org/libreoffice/core/tree/filter/source/xslt for the code.</xsl:comment>
161            <xsl:call-template name='create-header'>
162                <xsl:with-param name="globalData" select="$globalData" />
163            </xsl:call-template>
164
165            <xsl:call-template name='create-body'>
166                <xsl:with-param name="globalData" select="$globalData" />
167            </xsl:call-template>
168        </xsl:element>
169    </xsl:template>
170
171
172    <!-- debug purpose only:
173         verbose checking of the parameters of this template-->
174    <xsl:template name="debug-check-parameter">
175        <xsl:message>Parameter dpi: <xsl:value-of select="$dpi" /></xsl:message>
176        <xsl:message>Parameter metaFileURL: <xsl:value-of select="$metaFileURL" /></xsl:message>
177        <xsl:message>Parameter stylesFileURL: <xsl:value-of select="$stylesFileURL" /></xsl:message>
178        <xsl:message>Parameter sourceBaseURL: <xsl:value-of select="$sourceBaseURL" /></xsl:message>
179        <xsl:message>Parameter targetBaseURL: <xsl:value-of select="$targetBaseURL" /></xsl:message>
180        <xsl:message>Parameter onlyStyleOutputEnabled: <xsl:value-of select="$onlyStyleOutputEnabled" /></xsl:message>
181        <xsl:message>Parameter debugEnabled: <xsl:value-of select="$debugEnabled" /></xsl:message>
182        <xsl:message>Parameter java: <xsl:value-of select="$java" /></xsl:message>
183        <xsl:message>Parameter javaEnabled: <xsl:value-of select="$javaEnabled" /></xsl:message>
184    </xsl:template>
185
186</xsl:stylesheet>
187