mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-03-23 01:23:45 +08:00
优化项目结构、优化 maven 结构
This commit is contained in:
418
office-plugin/windows-office/share/xslt/export/common/body.xsl
Normal file
418
office-plugin/windows-office/share/xslt/export/common/body.xsl
Normal file
@@ -0,0 +1,418 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--***********************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
***********************************************************-->
|
||||
|
||||
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://xml.apache.org/xslt/java" xmlns:urlencoder="http://www.jclark.com/xt/java/java.net.URLEncoder" 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 java urlencoder">
|
||||
|
||||
|
||||
<xsl:include href="table_of_content.xsl"/>
|
||||
|
||||
|
||||
<!-- ****************** -->
|
||||
<!-- *** Whitespace *** -->
|
||||
<!-- ****************** -->
|
||||
|
||||
<xsl:template match="text:s">
|
||||
<xsl:call-template name="write-breakable-whitespace">
|
||||
<xsl:with-param name="whitespaces" select="@text:c"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!--write the number of 'whitespaces' -->
|
||||
<xsl:template name="write-breakable-whitespace">
|
||||
<xsl:param name="whitespaces"/>
|
||||
|
||||
<!--write two space chars as the normal white space character will be stripped
|
||||
and the other is able to break -->
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="$whitespaces >= 2">
|
||||
<xsl:call-template name="write-breakable-whitespace-2">
|
||||
<xsl:with-param name="whitespaces" select="$whitespaces - 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!--write the number of 'whitespaces' -->
|
||||
<xsl:template name="write-breakable-whitespace-2">
|
||||
<xsl:param name="whitespaces"/>
|
||||
<!--write two space chars as the normal white space character will be stripped
|
||||
and the other is able to break -->
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="$whitespaces >= 2">
|
||||
<xsl:call-template name="write-breakable-whitespace">
|
||||
<xsl:with-param name="whitespaces" select="$whitespaces - 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!-- currentSolution: 8 non-breakable-spaces instead of a TAB is an approximation.
|
||||
Sometimes less spaces than 8 might be needed and the output might be more difficult to read-->
|
||||
<xsl:template match="text:tab">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:call-template name="write-breakable-whitespace">
|
||||
<xsl:with-param name="whitespaces" select="8"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<!-- *************** -->
|
||||
<!-- *** Textbox *** -->
|
||||
<!-- *************** -->
|
||||
|
||||
<!-- ID / NAME of text-box -->
|
||||
<xsl:template match="@draw:name">
|
||||
<xsl:attribute name="id">
|
||||
<xsl:choose>
|
||||
<xsl:when test="number(substring(.,1,1))">
|
||||
<!-- Heuristic: If the first character is a number a 'a_' will be set
|
||||
as prefix, as id have to be of type NMTOKEN -->
|
||||
<xsl:value-of select="concat('a_',translate(., '
&<>.,;: %()[]/\+', '___________________________'))"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="translate(., '
&<>.,;: %()[]/\+', '___________________________')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="text:line-break">
|
||||
<xsl:param name="listIndent"/>
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="br"/>
|
||||
|
||||
<!-- line breaks in lists need an indent similar to the list label -->
|
||||
<xsl:if test="$listIndent">
|
||||
<xsl:element namespace="{$namespace}" name="span">
|
||||
<xsl:attribute name="style">margin-left:<xsl:value-of select="$listIndent"/>cm</xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- currently there have to be an explicit call of the style attribute nodes, maybe the attributes nodes have no priority only order relevant-->
|
||||
<xsl:template name="apply-styles-and-content">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:param name="footnotePrefix" />
|
||||
<xsl:apply-templates select="@*">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
<!-- the footnote symbol is the prefix for a footnote in the footer -->
|
||||
<xsl:copy-of select="$footnotePrefix"/>
|
||||
<xsl:apply-templates select="node()">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- ******************* -->
|
||||
<!-- *** References *** -->
|
||||
<!-- ******************* -->
|
||||
|
||||
<xsl:template match="text:reference-ref | text:sequence-ref">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:element namespace="{$namespace}" name="a">
|
||||
<xsl:attribute name="href">
|
||||
<xsl:text>#</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="number(substring(@text:ref-name,1,1))">
|
||||
<!-- Heuristic: If the first character is a number a 'a_' will be set
|
||||
as prefix, as id have to be of type NMTOKEN -->
|
||||
<xsl:value-of select="concat('a_',translate(@text:ref-name, '
&<>.,;: %()[]/\+', '___________________________'))"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="translate(@text:ref-name, '
&<>.,;: %()[]/\+', '___________________________')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
|
||||
<xsl:apply-templates select="@* | node()">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@text:name">
|
||||
<xsl:attribute name="id">
|
||||
<xsl:choose>
|
||||
<xsl:when test="number(substring(.,1,1))">
|
||||
<!-- Heuristic: If the first character is a number a 'a_' will be set
|
||||
as prefix, as id have to be of type NMTOKEN -->
|
||||
<xsl:value-of select="concat('a_',translate(., '
&<>.,;: %()[]/\+', '___________________________'))"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="translate(., '
&<>.,;: %()[]/\+', '___________________________')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:sequence">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="a">
|
||||
<xsl:apply-templates select="@*" />
|
||||
<xsl:attribute name="id">
|
||||
<xsl:choose>
|
||||
<xsl:when test="number(substring(@text:ref-name,1,1))">
|
||||
<!-- Heuristic: If the first character is a number a 'a_' will be set
|
||||
as prefix, as id have to be of type NMTOKEN -->
|
||||
<xsl:value-of select="concat('a_',translate(@text:ref-name, '
&<>.,;: %()[]/\+', '___________________________'))"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="translate(@text:ref-name, '
&<>.,;: %()[]/\+', '___________________________')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:element>
|
||||
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:reference-mark">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="a">
|
||||
<xsl:apply-templates select="@*" />
|
||||
<xsl:attribute name="id">
|
||||
<xsl:choose>
|
||||
<xsl:when test="number(substring(@text:name,1,1))">
|
||||
<!-- Heuristic: If the first character is a number a 'a_' will be set
|
||||
as prefix, as id have to be of type NMTOKEN -->
|
||||
<xsl:value-of select="concat('a_',translate(@text:name, '
&<>.,;: %()[]/\+', '___________________________'))"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="translate(@text:name, '
&<>.,;: %()[]/\+', '___________________________')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:element>
|
||||
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="text:reference-mark-start">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="a">
|
||||
<xsl:apply-templates select="@*" />
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:bibliography-mark">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="a">
|
||||
<xsl:apply-templates select="@* | node()">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<!-- @text:title exist only in text:bibliography-mark -->
|
||||
<xsl:template match="@text:title">
|
||||
<xsl:attribute name="title">
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<!-- @text:url exist only in text:bibliography-mark -->
|
||||
<xsl:template match="@text:url">
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:user-defined">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="office:annotation">
|
||||
<xsl:element name="span">
|
||||
<xsl:attribute name="title">annotation</xsl:attribute>
|
||||
<xsl:attribute name="class">annotation_style_by_filter</xsl:attribute>
|
||||
<xsl:apply-templates select="@*" />
|
||||
<br/>
|
||||
<xsl:text>[ANNOTATION:</xsl:text>
|
||||
<br/>
|
||||
<xsl:apply-templates select="*" mode="annotation"/>
|
||||
<xsl:text>]</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:p" mode="annotation">
|
||||
<br/>
|
||||
<xsl:element name="span">
|
||||
<xsl:text>NOTE: '</xsl:text>
|
||||
<xsl:apply-templates />
|
||||
<xsl:text>'</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="dc:creator" mode="annotation">
|
||||
<br/>
|
||||
<xsl:element name="span">
|
||||
<xsl:attribute name="title">dc:creator</xsl:attribute>
|
||||
<xsl:text>BY '</xsl:text>
|
||||
<xsl:apply-templates />
|
||||
<xsl:text>'</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="dc:date" mode="annotation">
|
||||
<br/>
|
||||
<xsl:element name="span">
|
||||
<xsl:attribute name="title">dc:date</xsl:attribute>
|
||||
<xsl:text>ON '</xsl:text>
|
||||
<xsl:apply-templates />
|
||||
<xsl:text>'</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="meta:date-string" mode="annotation">
|
||||
<br/>
|
||||
<xsl:element name="span">
|
||||
<xsl:attribute name="title">meta-date-string</xsl:attribute>
|
||||
<xsl:text>META DATE '</xsl:text>
|
||||
<xsl:apply-templates />
|
||||
<xsl:text>'</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- *************** -->
|
||||
<!-- *** HELPER *** -->
|
||||
<!-- *************** -->
|
||||
|
||||
|
||||
<xsl:template name="create-href">
|
||||
<xsl:param name="href"/>
|
||||
|
||||
<xsl:choose>
|
||||
<!-- internal OOo URL used in content tables -->
|
||||
<xsl:when test="contains($href, '%7Coutline')">
|
||||
<!-- the simple workaround for content tables in a single document is to create create an anchor from every heading element
|
||||
work-around downside: Multiple identical headings won't refer always to the first.
|
||||
-->
|
||||
<xsl:text>#</xsl:text>
|
||||
<xsl:variable name="title">
|
||||
<xsl:apply-templates mode="concatenate"/>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:value-of select="concat('a_', translate(normalize-space($title), '.,;: %()[]/\+', '_____________'))"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="self::draw:image[office:binary-data]">
|
||||
<xsl:text>data:image/*;base64,</xsl:text><xsl:value-of select="office:binary-data"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<!-- in case of packed open office document -->
|
||||
<xsl:when test="starts-with($sourceBaseURL, 'jar:') or $isPackageFormat">
|
||||
<xsl:choose>
|
||||
<!-- for images relative to open office document -->
|
||||
<xsl:when test="starts-with($href, '../')">
|
||||
<!-- creating an absolute http URL to the packed image file (removing the '.')-->
|
||||
<xsl:value-of select="concat(substring-after(substring-before($sourceBaseURL, '!'), 'jar:'), '/', $href, $optionalURLSuffix)"/>
|
||||
</xsl:when>
|
||||
<!-- for absolute URLs & absolute paths -->
|
||||
<xsl:when test="contains($href, ':') or starts-with($href, '/')">
|
||||
<xsl:value-of select="concat($href, $optionalURLSuffix)"/>
|
||||
</xsl:when>
|
||||
<!-- for images jared in open office document -->
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat($sourceBaseURL, $href, $optionalURLSuffix)"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<!-- for absolute URLs & Paths -->
|
||||
<xsl:when test="contains($href, ':') or starts-with($href, '/')">
|
||||
<xsl:value-of select="concat($href, $optionalURLSuffix)"/>
|
||||
</xsl:when>
|
||||
<!-- for relative URLs -->
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat($sourceBaseURL, $href, $optionalURLSuffix)"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text()" mode="concatenate">
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:template>
|
||||
<xsl:template match="*" mode="concatenate">
|
||||
<xsl:apply-templates mode="concatenate"/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- ******************** -->
|
||||
<!-- *** Common Rules *** -->
|
||||
<!-- ******************** -->
|
||||
|
||||
<!-- ignore / neglect the following elements -->
|
||||
<xsl:template match="draw:custom-shape | draw:g | office:forms | text:alphabetical-index-mark | text:alphabetical-index-mark-end | text:alphabetical-index-mark-start | text:bibliography-source | text:number | text:reference-mark-end | text:sequence-decls | text:soft-page-break | text:table-of-content-source | text:tracked-changes | text:user-field-decls"/>
|
||||
|
||||
<!-- default template used by purpose-->
|
||||
<xsl:template match="text:bibliography | text:change-end | text:change-start">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<!-- default template for not recognized elements -->
|
||||
<xsl:template match="*">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:message>Using default element rule for ODF element '<xsl:value-of select="name()"/>'.</xsl:message>
|
||||
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@*"/>
|
||||
|
||||
<!-- allowing all matched text nodes -->
|
||||
<xsl:template match="text()">
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--***********************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
***********************************************************-->
|
||||
|
||||
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" 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:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 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" exclude-result-prefixes="office table style text draw svg dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
|
||||
<xsl:template match="office:meta">
|
||||
<o:DocumentProperties>
|
||||
<o:Title>
|
||||
<xsl:value-of select="dc:title"/>
|
||||
</o:Title>
|
||||
<o:Subject>
|
||||
<xsl:value-of select="dc:subject"/>
|
||||
</o:Subject>
|
||||
<o:Keywords>
|
||||
<xsl:for-each select="meta:keywords/meta:keyword">
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:if test="position()!=last()">, </xsl:if>
|
||||
</xsl:for-each>
|
||||
</o:Keywords>
|
||||
<o:Description>
|
||||
<xsl:value-of select="dc:description"/>
|
||||
</o:Description>
|
||||
<o:Category>
|
||||
<xsl:value-of select="meta:user-defined[@meta:name = 'Category']"/>
|
||||
</o:Category>
|
||||
<o:Author>
|
||||
<xsl:value-of select="meta:initial-creator"/>
|
||||
</o:Author>
|
||||
<o:LastAuthor>
|
||||
<xsl:value-of select="dc:creator"/>
|
||||
</o:LastAuthor>
|
||||
<o:Manager>
|
||||
<xsl:value-of select="meta:user-defined[@meta:name = 'Manager']"/>
|
||||
</o:Manager>
|
||||
<o:Company>
|
||||
<xsl:value-of select="meta:user-defined[@meta:name = 'Company']"/>
|
||||
</o:Company>
|
||||
<o:HyperlinkBase>
|
||||
<xsl:value-of select="meta:user-defined[@meta:name = 'HyperlinkBase']"/>
|
||||
</o:HyperlinkBase>
|
||||
<o:Revision>
|
||||
<xsl:value-of select="meta:editing-cycles"/>
|
||||
</o:Revision>
|
||||
<!-- PresentationFormat, Guid, AppName, Version -->
|
||||
<o:TotalTime>
|
||||
<xsl:if test="meta:editing-duration">
|
||||
<xsl:variable name="hours">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(meta:editing-duration, 'H')">
|
||||
<xsl:value-of select="substring-before( substring-after( meta:editing-duration, 'PT'), 'H')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>0</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="minutes">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(meta:editing-duration, 'M') and contains(meta:editing-duration, 'H')">
|
||||
<xsl:value-of select="substring-before( substring-after( meta:editing-duration, 'H'), 'M')"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(meta:editing-duration, 'M')">
|
||||
<xsl:value-of select="substring-before( substring-after( meta:editing-duration, 'PT'), 'M')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>0</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="$hours * 60 + $minutes"/>
|
||||
</xsl:if>
|
||||
</o:TotalTime>
|
||||
<o:LastPrinted>
|
||||
<xsl:if test="meta:print-date">
|
||||
<xsl:value-of select="concat( meta:print-date, 'Z')"/>
|
||||
</xsl:if>
|
||||
</o:LastPrinted>
|
||||
<o:Created>
|
||||
<xsl:if test="meta:creation-date">
|
||||
<xsl:value-of select="concat( meta:creation-date, 'Z')"/>
|
||||
</xsl:if>
|
||||
</o:Created>
|
||||
<o:LastSaved>
|
||||
<xsl:if test="dc:date">
|
||||
<xsl:value-of select="concat( dc:date, 'Z')"/>
|
||||
</xsl:if>
|
||||
</o:LastSaved>
|
||||
<o:Pages>
|
||||
<xsl:value-of select="meta:document-statistic/@meta:page-count"/>
|
||||
</o:Pages>
|
||||
<o:Words>
|
||||
<xsl:value-of select="meta:document-statistic/@meta:word-count"/>
|
||||
</o:Words>
|
||||
<o:Characters>
|
||||
<xsl:value-of select="meta:document-statistic/@meta:character-count"/>
|
||||
</o:Characters>
|
||||
<!-- CharactersWithSpaces, Bytes, Lines -->
|
||||
<o:Paragraphs>
|
||||
<xsl:value-of select="meta:document-statistic/@meta:paragraph-count"/>
|
||||
</o:Paragraphs>
|
||||
</o:DocumentProperties>
|
||||
<o:CustomDocumentProperties>
|
||||
<o:Editor dt:dt="string">
|
||||
<xsl:value-of select="meta:generator"/>
|
||||
</o:Editor>
|
||||
<o:Language dt:dt="string">
|
||||
<xsl:value-of select="dc:language"/>
|
||||
</o:Language>
|
||||
<xsl:for-each select="meta:user-defined">
|
||||
<!-- transfer strings to XML QName, necessary to convert several characters -->
|
||||
<xsl:element name="{concat( 'o:', translate(@meta:name,'.,| ~`!@#$%^&<>*()+=[]{};:"/\?','_'))}">
|
||||
<xsl:attribute name="dt:dt">string</xsl:attribute>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:element>
|
||||
</xsl:for-each>
|
||||
</o:CustomDocumentProperties>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,824 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--***********************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
***********************************************************-->
|
||||
|
||||
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:xt="http://www.jclark.com/xt"
|
||||
xmlns:common="http://exslt.org/common"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
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 xt common xalan">
|
||||
|
||||
|
||||
|
||||
<!-- ***************************************** -->
|
||||
<!-- *** Gathering office style properties *** -->
|
||||
<!-- ***************************************** -->
|
||||
|
||||
<!-- REASON FOR STYLESHEET:
|
||||
In the OpenOffice documents styles are represented by a hierarchy.
|
||||
(e.g. most styles are inherited from a default style).
|
||||
Many other languages (as XHTML/CSS) do not support inherited styles.
|
||||
The style inheritance have to be made flat/absolute for each style.
|
||||
|
||||
A further reason was, that the earlier style collection mechanism
|
||||
had problems with CSS inline, which do not inherit from XML office defaults
|
||||
nor font:family defaults as the style header does
|
||||
(cp. stylesheet 'style_collector.xsl' and the 'write-default-styles' template)
|
||||
|
||||
RESULT OF STYLESHEET:
|
||||
All styles will be returned in a variable containing styles with their inherited *:
|
||||
|
||||
<all-styles>
|
||||
<style style:family="foo" style:name="x1">
|
||||
<* fo:padding-left="0cm" fo:margin-right="0cm" />
|
||||
</style>
|
||||
<style style:family="muh" style:name="x2" >
|
||||
<* fo:padding-left="3cm" ... />
|
||||
</style>
|
||||
...
|
||||
|
||||
</all-styles>
|
||||
-->
|
||||
|
||||
|
||||
<xsl:template name="collect-global-odf-properties">
|
||||
<!-- to access the variable as a node-set by XPATH expressions, it is necessary to convert it
|
||||
from a result-tree-fragment (RTF) to a node set by a in a XSLT 1.0 non standarized function -->
|
||||
<xsl:variable name="globalDataRTF">
|
||||
<xsl:call-template name="collect-document-links-RTF" />
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="collect-style-properties">
|
||||
<xsl:with-param name="globalData" select="common:node-set($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="collect-style-properties">
|
||||
<xsl:with-param name="globalData" select="xalan:nodeset($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="collect-style-properties">
|
||||
<xsl:with-param name="globalData" select="xt:node-set($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">The required node-set function was not found!</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<xsl:template name="collect-style-properties">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<!-- Add the input file references to the new collected style properties -->
|
||||
<xsl:variable name="globalDataRTF">
|
||||
<xsl:copy-of select="$globalData" />
|
||||
<xsl:call-template name="collect-style-properties-RTF">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="map-odf-style-properties">
|
||||
<xsl:with-param name="globalData" select="common:node-set($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="map-odf-style-properties">
|
||||
<xsl:with-param name="globalData" select="xalan:nodeset($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="map-odf-style-properties">
|
||||
<xsl:with-param name="globalData" select="xt:node-set($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">The required node-set function was not found!</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="collect-document-links-RTF">
|
||||
<!-- works for zipped office files, unzipped office files as for flat filter single office file format as well -->
|
||||
<xsl:variable name="documentLinksRTF">
|
||||
<xsl:choose>
|
||||
<xsl:when test="office:document-content">
|
||||
<xsl:element name="styles-file" namespace="">
|
||||
<xsl:copy-of select="document(concat($sourceBaseURL, 'styles.xml'), .)" />
|
||||
</xsl:element>
|
||||
<xsl:element name="meta-file" namespace="">
|
||||
<xsl:copy-of select="document(concat($sourceBaseURL, 'meta.xml'), .)" />
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:element name="styles-file" namespace="">
|
||||
<xsl:copy-of select="/" />
|
||||
</xsl:element>
|
||||
<xsl:element name="meta-file" namespace="">
|
||||
<xsl:copy-of select="/" />
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="collect-document-links">
|
||||
<xsl:with-param name="documentLinks" select="common:node-set($documentLinksRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="collect-document-links">
|
||||
<xsl:with-param name="documentLinks" select="xalan:nodeset($documentLinksRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="collect-document-links">
|
||||
<xsl:with-param name="documentLinks" select="xt:node-set($documentLinksRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">The required node-set function was not found!</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="collect-document-links">
|
||||
<xsl:param name="documentLinks" />
|
||||
|
||||
<xsl:element name="styles-file" namespace="">
|
||||
<xsl:copy-of select="$documentLinks/styles-file/*" />
|
||||
</xsl:element>
|
||||
|
||||
<xsl:element name="meta-file" namespace="">
|
||||
<xsl:copy-of select="$documentLinks/meta-file/*" />
|
||||
</xsl:element>
|
||||
|
||||
<xsl:copy-of select="$documentLinks/styles-file/*/office:styles" />
|
||||
<xsl:copy-of select="$documentLinks/styles-file/*/office:font-face-decls" />
|
||||
|
||||
<!-- office:automatic-styles may be containted in two files (i.e. content.xml and styles.xml).
|
||||
Wild card necessary as top level element differs from flat office files ("SampleName.fsxw") -->
|
||||
<xsl:copy-of select="/*/office:automatic-styles" />
|
||||
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="collect-style-properties-RTF">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<!--** DEFAULT STYLES: First adding some office defaults unwritten in XML -->
|
||||
<xsl:variable name="defaultOfficeStyle-RTF">
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:element name="style:properties" />
|
||||
</xsl:element>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="collect-properties-defaults">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="defaultOfficeStyle" select="common:node-set($defaultOfficeStyle-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="collect-properties-defaults">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="defaultOfficeStyle" select="xalan:nodeset($defaultOfficeStyle-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="collect-properties-defaults">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="defaultOfficeStyle" select="xt:node-set($defaultOfficeStyle-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: 'Nodeset'</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="collect-properties-defaults">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="defaultOfficeStyle" />
|
||||
|
||||
<!--** DEFAULT STYLES: Adding the default styles of a style:family, by adding each office:styles/style:default-style element **-->
|
||||
<xsl:variable name="defaultFamilyStyles-RTF">
|
||||
<xsl:for-each select="$globalData/office:styles/style:default-style">
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="@style:family" />
|
||||
<xsl:call-template name="create-inherited-style-properties">
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$defaultOfficeStyle/style/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="collect-properties">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="defaultOfficeStyle" select="$defaultOfficeStyle" />
|
||||
<xsl:with-param name="defaultFamilyStyles" select="common:node-set($defaultFamilyStyles-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="collect-properties">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="defaultOfficeStyle" select="$defaultOfficeStyle" />
|
||||
<xsl:with-param name="defaultFamilyStyles" select="xalan:nodeset($defaultFamilyStyles-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="collect-properties">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="defaultOfficeStyle" select="$defaultOfficeStyle" />
|
||||
<xsl:with-param name="defaultFamilyStyles" select="xt:node-set($defaultFamilyStyles-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="collect-properties">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="defaultOfficeStyle" />
|
||||
<xsl:param name="defaultFamilyStyles" />
|
||||
|
||||
<!--** traversee all style trees - branch after branch - collecting style properties **-->
|
||||
<xsl:element name="all-doc-styles" namespace="">
|
||||
|
||||
<!-- Background Information:
|
||||
|
||||
There are two different types of styles in the Office:
|
||||
1) The office:styles from the user pre-defined style templates
|
||||
2) The automatic:styles, which are created whenever a user uses explicit style formatting.
|
||||
|
||||
The office:styles only have parent styles in the office:styles,
|
||||
but automatic:styles may inherit from both office:styles and themself.
|
||||
-->
|
||||
|
||||
<!--** traversee all office:styles trees beginning with the top-level styles **-->
|
||||
<xsl:for-each select="$globalData/office:styles/style:style[not(@style:parent-style-name)]">
|
||||
<!-- Looking for parents from style:family
|
||||
<xsl:for-each select="$globalData/office:styles/style:style[@style:family=current()/@style:family][not(@style:parent-style-name)]"> -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="$defaultFamilyStyles/style[@style:family=current()/@style:family]">
|
||||
<xsl:call-template name="inherit-style-for-self-and-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$defaultFamilyStyles/style[@style:family=current()/@style:family]/*" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="false()" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="inherit-style-for-self-and-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$defaultOfficeStyle/style/*" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="false()" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<!--** creates a style element with style:name and style:family attribute and
|
||||
an element representing the absolute style properties style:property ** -->
|
||||
</xsl:for-each>
|
||||
|
||||
<!--** traversee all office:automatic-styles trees beginning with the top-level styles **-->
|
||||
<xsl:for-each select="$globalData/office:automatic-styles/style:style[not(@style:parent-style-name)]">
|
||||
<!--** creates a style element with style:name and style:family attribute and
|
||||
an element representing the absolute style properties style:property ** -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="$defaultFamilyStyles/style[@style:family=current()/@style:family]">
|
||||
<xsl:call-template name="inherit-style-for-self-and-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$defaultFamilyStyles/style[@style:family=current()/@style:family]/*" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="true()" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="inherit-style-for-self-and-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$defaultOfficeStyle/style/*" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="true()" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:for-each>
|
||||
|
||||
</xsl:element>
|
||||
<!-- debug output in case only styles should be given out (regression test) -->
|
||||
<xsl:if test="$onlyStyleOutputEnabled">
|
||||
<xsl:element name="defaultOfficeStyle" namespace="">
|
||||
<xsl:copy-of select="$defaultOfficeStyle" />
|
||||
</xsl:element>
|
||||
<xsl:element name="defaultFamilyStyles" namespace="">
|
||||
<xsl:copy-of select="$defaultFamilyStyles" />
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="inherit-style-for-self-and-children">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="inheritedStyleProperties" />
|
||||
<xsl:param name="searchOnlyInAutomaticStyles" />
|
||||
|
||||
<!--** create an absolute style by inherting properties from the given parent properties **-->
|
||||
<xsl:variable name="newStyleProperties-RTF">
|
||||
<xsl:call-template name="create-inherited-style-properties">
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$inheritedStyleProperties" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:variable name="newStyleProperties" select="common:node-set($newStyleProperties-RTF)" />
|
||||
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="@style:family" />
|
||||
<xsl:copy-of select="@style:name" />
|
||||
<xsl:copy-of select="$newStyleProperties" />
|
||||
</xsl:element>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$searchOnlyInAutomaticStyles">
|
||||
<xsl:call-template name="get-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="true()" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$newStyleProperties/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!--** for all automatic-children of the current office:styles **-->
|
||||
<xsl:call-template name="get-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="false()" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$newStyleProperties/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:variable name="newStyleProperties" select="xalan:nodeset($newStyleProperties-RTF)" />
|
||||
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="@style:family" />
|
||||
<xsl:copy-of select="@style:name" />
|
||||
<xsl:copy-of select="$newStyleProperties" />
|
||||
</xsl:element>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$searchOnlyInAutomaticStyles">
|
||||
<xsl:call-template name="get-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="true()" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$newStyleProperties/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!--** for all automatic-children of the current office:styles **-->
|
||||
<xsl:call-template name="get-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="false()" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$newStyleProperties/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:variable name="newStyleProperties" select="xt:node-set($newStyleProperties-RTF)" />
|
||||
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="@style:family" />
|
||||
<xsl:copy-of select="@style:name" />
|
||||
<xsl:copy-of select="$newStyleProperties" />
|
||||
</xsl:element>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$searchOnlyInAutomaticStyles">
|
||||
<xsl:call-template name="get-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="true()" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$newStyleProperties/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!--** for all automatic-children of the current office:styles **-->
|
||||
<xsl:call-template name="get-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="false()" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$newStyleProperties/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="get-children">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="searchOnlyInAutomaticStyles" />
|
||||
<xsl:param name="inheritedStyleProperties" select="*" />
|
||||
|
||||
<!-- QUESTION: Parent style is only unique by name and family, but what about cross family inheritance? -->
|
||||
<!-- For each child style (that is every style which has the given parentStyleName as style:parent-style-name and the same style:family -->
|
||||
<xsl:variable name="parentStyleFamily" select="@style:family" />
|
||||
<xsl:variable name="parentStyleName" select="@style:name" />
|
||||
<xsl:if test="not($searchOnlyInAutomaticStyles)">
|
||||
<xsl:for-each select="$globalData/office:styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
|
||||
<xsl:call-template name="inherit-style-for-self-and-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$inheritedStyleProperties" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="$searchOnlyInAutomaticStyles" />
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
</xsl:if>
|
||||
<xsl:for-each select="$globalData/office:automatic-styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
|
||||
<xsl:call-template name="inherit-style-for-self-and-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$inheritedStyleProperties" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="$searchOnlyInAutomaticStyles" />
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="create-inherited-style-properties">
|
||||
<xsl:param name="inheritedStyleProperties" />
|
||||
|
||||
<xsl:element name="style:properties">
|
||||
<!-- Writing all inherited style properties -->
|
||||
<xsl:for-each select="$inheritedStyleProperties/@*">
|
||||
<xsl:sort select="name()" />
|
||||
<xsl:copy-of select="." />
|
||||
</xsl:for-each>
|
||||
|
||||
<!--All current attributes will override already inserted attributes of the same name
|
||||
XSLT Spec: "Adding an attribute to an element replaces any existing attribute of that element with the same expanded-name." -->
|
||||
<xsl:for-each select="*/@*[name() != 'style:font-size-rel']">
|
||||
<xsl:copy-of select="." />
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:if test="*/@style:font-size-rel">
|
||||
<!--
|
||||
The intheritedStyleProperties should include a absolute Font Size, but
|
||||
<style:properties
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
style:font-name="Courier New"
|
||||
fo:language="en"
|
||||
fo:country="US"
|
||||
style:font-name-asian=Courier New"
|
||||
style:font-name-complex="Courier New"/>
|
||||
-->
|
||||
<xsl:variable name="fontSizeAbsolute">
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="$inheritedStyleProperties/@fo:font-size" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="fontSizeRelative">
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="*/@style:font-size-rel" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:attribute name="fo:font-size">
|
||||
<xsl:value-of select="$fontSizeAbsolute + $fontSizeRelative"/>
|
||||
<xsl:text>pt</xsl:text>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<!-- providing tabulator indentation -->
|
||||
<xsl:copy-of select="$inheritedStyleProperties/style:tab-stops"/>
|
||||
<xsl:copy-of select="*/style:tab-stops"/>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<!-- debugging & testing purpose -->
|
||||
<xsl:template name="write-collected-styles">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<xsl:message><all-doc-styles></xsl:message>
|
||||
<xsl:for-each select="$globalData/all-doc-styles/style">
|
||||
<xsl:message><style</xsl:message>
|
||||
<xsl:message>style:family="<xsl:value-of select="current()/@style:family" />"></xsl:message>
|
||||
<xsl:message>style:name="<xsl:value-of select="current()/@style:name" />" </xsl:message>
|
||||
<xsl:message> <*</xsl:message>
|
||||
<xsl:for-each select="*/@*">
|
||||
<xsl:message>
|
||||
<xsl:text></xsl:text>
|
||||
<xsl:value-of select="name()" />="<xsl:value-of select="." />"</xsl:message>
|
||||
</xsl:for-each>
|
||||
<xsl:message>/></xsl:message>
|
||||
<xsl:message></style></xsl:message>
|
||||
</xsl:for-each>
|
||||
<xsl:message></all-doc-styles></xsl:message>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="map-odf-style-properties">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<xsl:choose>
|
||||
<!--+++++ DEBUG STYLE OUTPUT FOR REGRESSION TEST +++++-->
|
||||
<!-- create styles file from the style variable (testing switch) -->
|
||||
<xsl:when test="$onlyStyleOutputEnabled">
|
||||
|
||||
<xsl:element name="debug-output" namespace="">
|
||||
<xsl:copy-of select="$globalData" />
|
||||
<xsl:call-template name="map-odf-properties">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
|
||||
<!-- create XHTML file -->
|
||||
<xsl:otherwise>
|
||||
<!-- to access the variable like a node-set it is necessary to convert it
|
||||
from a result-tree-fragment (RTF) to a node set using the James Clark extension -->
|
||||
<xsl:variable name="globalDataRTF">
|
||||
<!-- raw properties still needed for table width attribute creation -->
|
||||
<xsl:copy-of select="$globalData" />
|
||||
<xsl:call-template name="map-odf-properties">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="start-main">
|
||||
<xsl:with-param name="globalData" select="common:node-set($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="start-main">
|
||||
<xsl:with-param name="globalData" select="xalan:nodeset($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="start-main">
|
||||
<xsl:with-param name="globalData" select="xt:node-set($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- REASON FOR TEMPLATE:
|
||||
The OpenOffice style properities gathered in the variable 'globalData' have to be mapped to the CSS style format
|
||||
-->
|
||||
<xsl:template name="map-odf-properties">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:element name="all-styles" namespace="">
|
||||
<xsl:for-each select="$globalData/all-doc-styles/style">
|
||||
<xsl:sort select="@style:family" />
|
||||
<xsl:sort select="@style:name" />
|
||||
|
||||
<xsl:call-template name="writeUsedStyles">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="style" select="."/>
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:key name="elementUsingStyle" match="*" use="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name | @table:default-cell-style-name"/>
|
||||
<xsl:key name="listLabelStyleInStyles" match="/*/office:styles/text:list-style/* |
|
||||
/*/office:styles/style:graphic-properties/text:list-style/*" use="@text:style-name"/>
|
||||
|
||||
<xsl:key name="listLabelStyleInContent" match="/*/office:automatic-styles/text:list-style/* | /*/office:automatic-styles/style:graphic-properties/text:list-style/*" use="@text:style-name"/>
|
||||
|
||||
|
||||
<xsl:variable name="documentRoot" select="/" />
|
||||
<xsl:template name="writeUsedStyles">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="style"/>
|
||||
|
||||
<!-- for-each changes the key environment from the previously globalData back to the document root -->
|
||||
<xsl:for-each select="$documentRoot">
|
||||
<!-- only styles, which are used in the content are written as CSS styles -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="key('elementUsingStyle', $style/@style:name)/@* or key('listLabelStyleInContent', $style/@style:name)/@*">
|
||||
<xsl:call-template name="writeUsedStyles2">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="style" select="$style" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="not(office:document-content)">
|
||||
<xsl:if test="key('listLabelStyleInStyles', $style/@style:name)/@* or /*/office:styles/text:notes-configuration[@text:citation-style-name = $style/@style:name or /*/office:styles/@text:citation-body-style-name=$style/@style:name]">
|
||||
<!-- if there are consecutive paragraphs with borders (OR background AND margin ), only the first and the last have the top/bottom border
|
||||
unless style:join-border="false" -->
|
||||
<xsl:call-template name="writeUsedStyles2">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="style" select="$style" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:for-each select="document($stylesFileURL)">
|
||||
<xsl:if test="key('listLabelStyleInStyles', $style/@style:name)/@* or /*/office:styles/text:notes-configuration[@text:citation-style-name = $style/@style:name or /*/office:styles/@text:citation-body-style-name=$style/@style:name]">
|
||||
<!-- if there are consecutive paragraphs with borders (OR background AND margin ), only the first and the last have the top/bottom border
|
||||
unless style:join-border="false" -->
|
||||
<xsl:call-template name="writeUsedStyles2">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="style" select="$style" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="writeUsedStyles2">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="style"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="
|
||||
$style/@style:family='paragraph'
|
||||
and((
|
||||
(
|
||||
$style/*/@fo:border-top
|
||||
or $style/*/@fo:border-bottom
|
||||
or $style/*/@fo:border
|
||||
)
|
||||
and
|
||||
(
|
||||
not($style/*/@style:join-border)
|
||||
or $style/*/@style:join-border = 'true'
|
||||
)
|
||||
)
|
||||
or
|
||||
(
|
||||
(
|
||||
$style/*/@fo:margin-top
|
||||
or $style/*/@fo:margin-bottom
|
||||
or $style/*/@fo:margin
|
||||
)
|
||||
and
|
||||
( $style/*/@fo:background-color
|
||||
and
|
||||
not($style/*/fo:background-color='transparent')
|
||||
)
|
||||
)
|
||||
)">
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="$style/@style:family" />
|
||||
<xsl:attribute name="style:name"><xsl:value-of select="concat($style/@style:name, '_borderStart')" /></xsl:attribute>
|
||||
<xsl:element name="final-properties" namespace="">
|
||||
<xsl:apply-templates select="$style/*/@*[not(name() = 'fo:border-bottom')][not(name() = 'fo:padding-bottom')][not(name() = 'fo:margin-bottom')][not(name() = 'fo:margin')]">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates mode="paragraphMerge" select="$style/*/@*[name() = 'fo:margin-bottom' or name() = 'fo:margin']">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:text> border-bottom-style:none; </xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="$style/@style:family" />
|
||||
<xsl:copy-of select="$style/@style:name" />
|
||||
<xsl:attribute name="mergedBorders"><xsl:value-of select="true()" /></xsl:attribute>
|
||||
<xsl:element name="final-properties" namespace="">
|
||||
<xsl:apply-templates select="$style/*/@*[not(name() = 'fo:border-top') and not(name() = 'fo:border-bottom')][not(name() = 'fo:padding-top') and not(name() = 'fo:padding-bottom')][not(name() = 'fo:margin-top') and not(name() = 'fo:margin-bottom')][not(name() = 'fo:margin')]">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates mode="paragraphMerge" select="$style/*/@*[name() = 'fo:margin-top' or name() = 'fo:margin-bottom' or name() = 'fo:margin']">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:text> border-top-style:none; border-bottom-style:none; </xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="$style/@style:family" />
|
||||
<xsl:attribute name="style:name"><xsl:value-of select="concat($style/@style:name, '_borderEnd')" /></xsl:attribute>
|
||||
<xsl:element name="final-properties" namespace="">
|
||||
<xsl:apply-templates select="$style/*/@*[not(name() = 'fo:border-top')][not(name() = 'fo:padding-top')][not(name() = 'fo:margin-top')][not(name() = 'fo:margin')]">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates mode="paragraphMerge" select="$style/*/@*[name() = 'fo:margin-top' or name() = 'fo:margin']">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:text> border-top-style:none;</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="not(key('listLabelStyleInStyles', $style/@style:name)/@*)">
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="$style/@style:family" />
|
||||
<xsl:copy-of select="$style/@style:name" />
|
||||
<xsl:element name="final-properties" namespace="">
|
||||
<xsl:apply-templates select="$style/*/@*">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:attribute name="style:family">none</xsl:attribute>
|
||||
<xsl:attribute name="style:name"><xsl:value-of select="$style/@style:name"/></xsl:attribute>
|
||||
<xsl:element name="final-properties" namespace="">
|
||||
<xsl:apply-templates select="$style/*/@*">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template mode="paragraphMerge" match="@fo:margin | @fo:margin-top | @fo:margin-bottom | @fo:margin-left | @fo:margin-right">
|
||||
<xsl:text>padding</xsl:text>
|
||||
<xsl:value-of select="substring-after(name(), 'fo:margin')"/>
|
||||
<xsl:text>:</xsl:text>
|
||||
<!-- Map once erroneusly used inch shortage 'inch' to CSS shortage 'in' -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(., 'inch')">
|
||||
<xsl:value-of select="substring-before(.,'ch')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,351 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--***********************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
***********************************************************-->
|
||||
|
||||
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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">
|
||||
|
||||
|
||||
<!-- *** Properties with a 'fo:' prefix *** -->
|
||||
<xsl:template match="@fo:background-color">
|
||||
<xsl:text>background-color:</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@fo:border | @fo:border-top | @fo:border-bottom | @fo:border-left | @fo:border-right">
|
||||
<xsl:variable name="borderType" select="substring-after(name(), ':')"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test=". = 'none'">
|
||||
<xsl:value-of select="$borderType"/>
|
||||
<xsl:text>-style:none; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="borderWidth" select="substring-before(., ' ')"/>
|
||||
<xsl:variable name="borderStyle" select="substring-before(substring-after(., ' '), ' ')"/>
|
||||
<xsl:variable name="borderColor" select="substring-after(substring-after(., ' '), ' ')"/>
|
||||
|
||||
<!-- More information at template 'round-up-border-width' -->
|
||||
<xsl:variable name="borderWidthFixed">
|
||||
<xsl:call-template name="round-up-border-width">
|
||||
<xsl:with-param name="borderWidth" select="$borderWidth"/>
|
||||
<xsl:with-param name="multiplier">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$borderStyle = 'double'">3</xsl:when>
|
||||
<xsl:otherwise>1</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:value-of select="$borderType"/>
|
||||
<xsl:text>-width:</xsl:text>
|
||||
<xsl:value-of select="$borderWidthFixed"/>
|
||||
<xsl:text>; </xsl:text>
|
||||
<xsl:value-of select="$borderType"/>
|
||||
<xsl:text>-style:</xsl:text>
|
||||
<xsl:value-of select="$borderStyle"/>
|
||||
<xsl:text>; </xsl:text>
|
||||
<xsl:value-of select="$borderType"/>
|
||||
<xsl:text>-color:</xsl:text>
|
||||
<xsl:value-of select="$borderColor"/>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- NOTE: Still there have to be placed a <br clear='all' /> to disable the flow!!!!-->
|
||||
<xsl:template match="@fo:clear">
|
||||
<xsl:text>clear:both; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<!-- text-shadow is a CSS2 feature and yet not common used in user-agents -->
|
||||
<xsl:template match="@fo:color |@svg:font-family |@fo:font-size |@fo:font-style |@fo:font-weight |@fo:text-indent |@fo:text-shadow">
|
||||
<xsl:value-of select="substring-after(name(), ':')"/>
|
||||
<xsl:text>:</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Maps fo:margin as well fo:margin-top, fo:margin-bottom, fo:padding-left, fo:margin-right -->
|
||||
<!-- Maps fo:padding as well fo:padding-top, fo:padding-bottom, fo:padding-left, fo:padding-right -->
|
||||
<xsl:template match="@fo:letter-spacing | @fo:line-height | @fo:width |@fo:margin | @fo:margin-top | @fo:margin-bottom | @fo:margin-left | @fo:margin-right | @fo:padding | @fo:padding-top | @fo:padding-bottom | @fo:padding-left | @fo:padding-right">
|
||||
<xsl:value-of select="substring-after(name(), ':')"/>
|
||||
<xsl:text>:</xsl:text>
|
||||
<!-- Map once erroneusly used inch shortage 'inch' to CSS shortage 'in' -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(., 'inch')">
|
||||
<xsl:value-of select="substring-before(.,'ch')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@fo:text-align">
|
||||
<!-- 'important' is necessary as table cell value alignment is decided by runtime over the valuetype
|
||||
Otherwise a table cell style-class would always be outnumbered by the run-time alignment value -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(., 'start')">
|
||||
<xsl:choose>
|
||||
<xsl:when test="parent::*/@style:writing-mode and contains(parent::*/@style:writing-mode, 'rl')">
|
||||
<xsl:text>text-align:right ! important; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>text-align:left ! important; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(., 'end')">
|
||||
<xsl:choose>
|
||||
<xsl:when test="parent::*/@style:writing-mode and contains(parent::*/@style:writing-mode, 'rl')">
|
||||
<xsl:text>text-align:left ! important;</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>text-align:right ! important; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>text-align:</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text> ! important; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:vertical-align">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(., 'bottom')">
|
||||
<xsl:text>vertical-align:bottom; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(., 'middle')">
|
||||
<xsl:text>vertical-align:middle; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>vertical-align:top; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- *** Properties with a 'style:' prefix *** -->
|
||||
<!-- NOTE: Can 'inside' | 'from-inside' better be handled:
|
||||
<!ATTLIST * style:horizontal-pos (from-left|left|center|right|from-inside|inside|outside)#IMPLIED>-->
|
||||
<xsl:template match="@style:horizontal-pos">
|
||||
<xsl:choose>
|
||||
<xsl:when test=".='left'">
|
||||
<xsl:text>text-align:left; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=". = 'right'">
|
||||
<xsl:text>text-align:right; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=".='center'">
|
||||
<xsl:text>text-align:center; </xsl:text>
|
||||
</xsl:when>
|
||||
<!-- NOTE: currently other values are not used.
|
||||
If the property value is from-left or from-inside,
|
||||
the svg:x attribute associated with the frame element specifies
|
||||
the horizontal position of the frame.
|
||||
Otherwise the svg:x attribute is ignored for text documents.
|
||||
-->
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:column-width">
|
||||
<xsl:text>width:</xsl:text>
|
||||
<xsl:choose>
|
||||
<!-- changing the distance measure: inch to in -->
|
||||
<xsl:when test="contains(., 'inch')">
|
||||
<xsl:value-of select="substring-before(.,'ch')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:text-underline-style">
|
||||
<xsl:text>text-decoration:</xsl:text>
|
||||
<xsl:choose>
|
||||
<!-- changing the distance measure: inch to in -->
|
||||
<xsl:when test=".='none'">
|
||||
<xsl:text>none ! important</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>underline</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:font-name">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<xsl:text>font-family:</xsl:text>
|
||||
<xsl:variable name="content" select="."/>
|
||||
<xsl:variable name="quote">'</xsl:variable>
|
||||
<xsl:variable name="fontName" select="$globalData/office:font-face-decls/style:font-face[@style:name=$content]/@svg:font-family" />
|
||||
<xsl:value-of select="translate($fontName, $quote, '')"/>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:row-height">
|
||||
<xsl:text>height:</xsl:text>
|
||||
<xsl:choose>
|
||||
<!-- changing the distance measure: inch to in -->
|
||||
<xsl:when test="contains(., 'inch')">
|
||||
<xsl:value-of select="substring-before(.,'ch')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@svg:strikethrough-position">
|
||||
<xsl:if test="not(.='none')">
|
||||
<xsl:text>text-decoration:line-through; </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="@style:text-position">
|
||||
<xsl:if test="contains(., 'sub')">
|
||||
<xsl:text>vertical-align:sub; </xsl:text>
|
||||
<xsl:if test="contains(., '%')">
|
||||
<xsl:text>font-size:</xsl:text>
|
||||
<xsl:value-of select="substring-after(., 'sub ')"/>
|
||||
<xsl:text>;</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:if test="contains(., 'super')">
|
||||
<xsl:text>vertical-align:super; </xsl:text>
|
||||
<xsl:if test="contains(., '%')">
|
||||
<xsl:text>font-size:</xsl:text>
|
||||
<xsl:value-of select="substring-after(., 'super ')"/>
|
||||
<xsl:text>;</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:vertical-pos">
|
||||
<xsl:choose>
|
||||
<xsl:when test=".='from-top'">
|
||||
<xsl:text>vertical-align:top; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>vertical-align:</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:width">
|
||||
<xsl:text>width:</xsl:text>
|
||||
<xsl:choose>
|
||||
<!-- changing the distance measure: inch to in -->
|
||||
<xsl:when test="contains(., 'inch')">
|
||||
<xsl:value-of select="substring-before(.,'ch')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
<xsl:template match="@style:wrap">
|
||||
<xsl:choose>
|
||||
<xsl:when test=".='left'">
|
||||
<xsl:text>float:right; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=".='right'">
|
||||
<xsl:text>float:left; </xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template match="@style:writing-mode">
|
||||
<xsl:text>writing-mode:</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
<!-- *** Properties with a no 'fo:' or 'style:' prefix *** -->
|
||||
<xsl:template match="@table:align">
|
||||
<xsl:choose>
|
||||
<xsl:when test=".='left'">
|
||||
<!-- Note: problems with meeting minutes example
|
||||
<xsl:text>float:right; </xsl:text> --></xsl:when>
|
||||
<xsl:when test=".='right'">
|
||||
<!-- Note: problems with meeting minutes example
|
||||
<xsl:text>float:left; </xsl:text> --></xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>float:none; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="style:background-image">
|
||||
<xsl:text>background-image:url(</xsl:text>
|
||||
<xsl:value-of select="@xlink:href"/>
|
||||
<xsl:text>); </xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@style:repeat = 'repeat'">
|
||||
<xsl:text>background-repeat:repeat; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>background-repeat:no-repeat; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Changing border width measure to cm and enlarging border-width to the Mozilla browser(1.7)
|
||||
visible minimum width
|
||||
- 0.0133cm for solid style
|
||||
- 0.0399cm for double style
|
||||
as there are three border lines painted -->
|
||||
<xsl:template name="round-up-border-width">
|
||||
<xsl:param name="borderWidth"/>
|
||||
<xsl:param name="multiplier"/>
|
||||
|
||||
<xsl:variable name="borderWidthByCentimeter">
|
||||
<xsl:call-template name="convert2cm">
|
||||
<xsl:with-param name="value" select="$borderWidth"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="minimalBorderWidth" select="0.0133 * $multiplier"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="number($borderWidthByCentimeter) < $minimalBorderWidth">
|
||||
<xsl:value-of select="$minimalBorderWidth"/>
|
||||
<xsl:text>cm</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$borderWidthByCentimeter"/>
|
||||
<xsl:text>cm</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--***********************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
***********************************************************-->
|
||||
|
||||
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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">
|
||||
|
||||
|
||||
<!-- table row handling -->
|
||||
<xsl:include href="table_rows.xsl" />
|
||||
<!-- table column handling -->
|
||||
<xsl:include href="table_columns.xsl" />
|
||||
<!-- table cell handling -->
|
||||
<xsl:include href="table_cells.xsl" />
|
||||
|
||||
<xsl:param name="tableElement" select="'table'" />
|
||||
|
||||
<!-- ******************* -->
|
||||
<!-- *** main table *** -->
|
||||
<!-- ******************* -->
|
||||
|
||||
|
||||
<xsl:template match="table:table" name="table:table">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<!-- The table will only be created if the table:scenario is active -->
|
||||
<xsl:if test="not(table:scenario) or table:scenario/@table:is-active">
|
||||
<xsl:call-template name="create-table">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<xsl:template name="create-table">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<!-- by default '1', for each new sub/inner/nested table the number counts one up -->
|
||||
<xsl:variable name="tableLevel" select="count(ancestor-or-self::table:table)" />
|
||||
<!-- collecting all visible "table:table-row" elements of the table -->
|
||||
<xsl:variable name="allVisibleTableRows" select="table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel] |
|
||||
table:table-header-rows/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel] |
|
||||
table:table-row-group/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel]" />
|
||||
<!-- As the alignment of a table is by 'align' attribut is deprecated and as the CSS 'float' attribute not well displayed,
|
||||
we do a trick by encapsulating the table with a aligned 'div' element-->
|
||||
<xsl:variable name="table-alignment" select="key('styles', @style:name = current()/@table:style-name)/*/@table:align" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($table-alignment) != 0">
|
||||
<xsl:element namespace="{$namespace}" name="div">
|
||||
<xsl:attribute name="style">
|
||||
<xsl:choose>
|
||||
<xsl:when test='$table-alignment="left" or $table-alignment="margins"'>
|
||||
<xsl:text>text-align:left</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$table-alignment="right"'>
|
||||
<xsl:text>text-align:right</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$table-alignment="center"'>
|
||||
<xsl:text>text-align:center</xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
<xsl:call-template name="create-table-element">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="create-table-element">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="create-table-element">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allVisibleTableRows" />
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="{$tableElement}">
|
||||
<xsl:attribute name="border">0</xsl:attribute>
|
||||
<xsl:attribute name="cellspacing">0</xsl:attribute>
|
||||
<xsl:attribute name="cellpadding">0</xsl:attribute>
|
||||
<xsl:choose>
|
||||
<xsl:when test='name()="table:table"'>
|
||||
<xsl:variable name="value" select="$globalData/all-doc-styles/style[@style:name = current()/@table:style-name]/*/@style:rel-width" />
|
||||
<xsl:if test="$value">
|
||||
<xsl:attribute name="width">
|
||||
<xsl:value-of select="$value" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="width">100%</xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:apply-templates select="@table:style-name">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
|
||||
<xsl:call-template name="create-column-style-variable">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,275 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--***********************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
***********************************************************-->
|
||||
|
||||
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:xt="http://www.jclark.com/xt"
|
||||
xmlns:common="http://exslt.org/common"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
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 xt common xalan">
|
||||
|
||||
|
||||
<!-- *********************************** -->
|
||||
<!-- *** write repeating table cells *** -->
|
||||
<!-- *********************************** -->
|
||||
|
||||
|
||||
<!-- matching cells to give out -> covered table cells are not written out -->
|
||||
<xsl:template match="table:table-cell">
|
||||
<xsl:param name="globalData" />
|
||||
<!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="maxRowLength" />
|
||||
<xsl:param name="tableDataType" />
|
||||
|
||||
|
||||
<!-- The column position of the current cell has to be determined
|
||||
to get the adequate column styles during later cell creation,
|
||||
or hiding the cell when @table:visibility is not set to 'visible'.
|
||||
|
||||
The position is archieved by adding up all table:number-columns-repeated of the preceding cells.
|
||||
Step1: creating '$precedingCells/quantity/@table:number-columns-repeated').
|
||||
Step2: sum(xxx:nodeset($precedingCells)/quantity) + 1 -->
|
||||
<xsl:variable name="precedingCells">
|
||||
<xsl:for-each select="preceding-sibling::*">
|
||||
<xsl:choose>
|
||||
<!-- maybe a parser is used, which reads the DTD files (e.g. Xerces),
|
||||
then '1' is the default for 'table:number-columns-repeated' -->
|
||||
<xsl:when test="not(@table:number-columns-repeated and @table:number-columns-repeated > 1)">
|
||||
<xsl:element name="quantity" namespace="">
|
||||
<xsl:text>1</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:element name="quantity" namespace="">
|
||||
<xsl:value-of select="@table:number-columns-repeated" />
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
|
||||
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="create-table-cell">
|
||||
<!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="precedingColumns" select="sum(common:node-set($precedingCells)/*)" />
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="create-table-cell">
|
||||
<!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="precedingColumns" select="sum(xalan:nodeset($precedingCells)/*)" />
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="create-table-cell">
|
||||
<!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="precedingColumns" select="sum(xt:node-set($precedingCells)/*)" />
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- current node is a table:table-cell -->
|
||||
<xsl:template name="create-table-cell">
|
||||
<!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="maxRowLength" />
|
||||
<xsl:param name="precedingColumns" select="0" />
|
||||
<xsl:param name="tableDataType" />
|
||||
|
||||
<xsl:variable name="columnPosition" select="$precedingColumns + 1" />
|
||||
|
||||
<xsl:if test="$debugEnabled">
|
||||
<xsl:message>
|
||||
<xsl:text>
|
||||
table:table-cell #</xsl:text>
|
||||
<xsl:value-of select="$columnPosition" />
|
||||
<xsl:text> has been entered with node value: </xsl:text>
|
||||
<xsl:value-of select="." />
|
||||
<xsl:text>
|
||||
table:number-columns-repeated: </xsl:text>
|
||||
<xsl:value-of select="@table:number-columns-repeated" />
|
||||
<xsl:text>
|
||||
maxRowLength: </xsl:text>
|
||||
<xsl:value-of select="$maxRowLength" />
|
||||
</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<!-- only non hidden column will be given out -->
|
||||
<xsl:variable name="currentTableColumn" select="$allTableColumns/table:table-column[position() = $columnPosition]" />
|
||||
<xsl:if test="$currentTableColumn[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]">
|
||||
<xsl:choose>
|
||||
<!-- if parser reads DTD the default is set to '1' -->
|
||||
<xsl:when test="@table:number-columns-repeated > 1">
|
||||
<!-- writes multiple entries of a cell -->
|
||||
<xsl:call-template name="repeat-write-cell">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="columnPosition" select="$columnPosition" />
|
||||
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="numberColumnsRepeated" select="@table:number-columns-repeated" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- writes an entry of a cell -->
|
||||
<xsl:call-template name="write-cell">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="columnPosition" select="$columnPosition" />
|
||||
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="repeat-write-cell">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="columnPosition" />
|
||||
<xsl:param name="currentTableColumn" />
|
||||
<xsl:param name="maxRowLength" />
|
||||
<xsl:param name="numberColumnsRepeated" />
|
||||
<xsl:param name="tableDataType" />
|
||||
|
||||
<xsl:choose>
|
||||
<!-- This is the current workaround for the flood of cells, simulation background by repeating cell -->
|
||||
<xsl:when test="$numberColumnsRepeated > 1 and $maxRowLength > $columnPosition">
|
||||
|
||||
<!-- writes an entry of a cell -->
|
||||
<xsl:call-template name="write-cell">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="columnPosition" select="$columnPosition" />
|
||||
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
<!-- repeat calling this method until all elements written out -->
|
||||
<xsl:if test="$debugEnabled">
|
||||
<xsl:message>+++++++++ cell repetition +++++++++</xsl:message>
|
||||
</xsl:if>
|
||||
<xsl:call-template name="repeat-write-cell">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="columnPosition" select="$columnPosition + 1" />
|
||||
<xsl:with-param name="currentTableColumn" select="$allTableColumns/table:table-column[position() = ($columnPosition + 1)]" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="numberColumnsRepeated" select="$numberColumnsRepeated - 1" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- This is the current workaround for the flood of cells, simulation background by repeating cell -->
|
||||
<!-- When the maxRowLength is reached a last entry of a cell is written -->
|
||||
<xsl:call-template name="write-cell">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="columnPosition" select="$columnPosition" />
|
||||
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="write-cell">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="columnPosition" />
|
||||
<xsl:param name="currentTableColumn" />
|
||||
<xsl:param name="tableDataType" />
|
||||
|
||||
<!-- a non hidden column will be give out -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="$currentTableColumn[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]">
|
||||
<xsl:call-template name="create-table-cell-content">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="columnPosition" select="$columnPosition" />
|
||||
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<!-- a hidden column -->
|
||||
<xsl:otherwise>
|
||||
<xsl:if test="$debugEnabled">
|
||||
<xsl:message>table column is hidden!</xsl:message>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,239 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--***********************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
***********************************************************-->
|
||||
|
||||
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:xt="http://www.jclark.com/xt"
|
||||
xmlns:common="http://exslt.org/common"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
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 xt common xalan">
|
||||
|
||||
<xsl:param name="tableColumnElement" select="'col'" />
|
||||
|
||||
<!-- ******************************************** -->
|
||||
<!-- *** Create table columns style variable *** -->
|
||||
<!-- ******************************************** -->
|
||||
|
||||
<!-- current node is a table:table -->
|
||||
<xsl:template name="create-column-style-variable">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allVisibleTableRows" />
|
||||
|
||||
<!-- all columns of the table -->
|
||||
<xsl:variable name="allTableColumns" select="table:table-column |
|
||||
table:table-column-group/descendant::table:table-column |
|
||||
table:table-header-columns/descendant::table:table-column" />
|
||||
<!-- allTableColumns: Containing all columns of the table, hidden and viewed.
|
||||
- if a column is hidden, if table:visibility has the value 'collapse' or 'filter', otherwise the value is 'visible'
|
||||
- if a column is being repeated, each repeated column is explicitly written as entry in this variable.
|
||||
Later (during template "write-cell") the style of the column will be mixed with the cell-style by using
|
||||
the position() of the column entry and comparing it with the iterating cell number. -->
|
||||
<xsl:variable name="allTableColumns-RTF">
|
||||
<xsl:for-each select="$allTableColumns">
|
||||
<xsl:call-template name="adding-column-styles-entries">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="create-table-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
<xsl:with-param name="allTableColumns" select="common:node-set($allTableColumns-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="create-table-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
<xsl:with-param name="allTableColumns" select="xalan:nodeset($allTableColumns-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="create-table-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
<xsl:with-param name="allTableColumns" select="xt:node-set($allTableColumns-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- current node is a table:table -->
|
||||
<xsl:template name="create-table-children">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allVisibleTableRows" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
|
||||
|
||||
<xsl:for-each select="$allTableColumns/table:table-column">
|
||||
<xsl:if test="not(@table:visibility = 'collapse' or @table:visibility = 'filter')">
|
||||
|
||||
<xsl:call-template name="create-column-element">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:call-template name="create-table-rows">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<!-- To be OVERWRITTEN -->
|
||||
<xsl:template name="create-column-element" />
|
||||
|
||||
<!-- current node is a table:table-column -->
|
||||
<xsl:template name="adding-column-styles-entries">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
|
||||
<xsl:choose>
|
||||
<!-- if parser reads DTD the default is set to '1' -->
|
||||
<xsl:when test="not(@table:number-columns-repeated and @table:number-columns-repeated > 1)">
|
||||
<!-- writes an entry of a column in the columns-variable -->
|
||||
<xsl:copy-of select="." />
|
||||
</xsl:when>
|
||||
<!-- No higher repetition of cells greater than 99 for the last and second last column.
|
||||
This is a workaround for some sample document (Waehrungsumrechner.sxc),
|
||||
having 230 repeated columns in the second last column to emulate background -->
|
||||
<!-- NOTE: Testcase with a table containing table:table-column-group and/or table:table-header-columns -->
|
||||
<xsl:when test="(last() or (last() - 1)) and @table:number-columns-repeated > 99">
|
||||
<!-- writes an entry of a column in the columns-variable -->
|
||||
<xsl:call-template name="repeat-adding-table-column">
|
||||
<xsl:with-param name="numberColumnsRepeated" select="1" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- repeated colums will be written explicit several times in the variable-->
|
||||
<xsl:call-template name="repeat-adding-table-column">
|
||||
<xsl:with-param name="numberColumnsRepeated" select="@table:number-columns-repeated" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- WRITES THE REPEATED COLUMN STYLE EXPLICIT AS AN ELEMENT IN THE COLUMNS-VARIABLE -->
|
||||
<!-- current node is a table:table-column -->
|
||||
<xsl:template name="repeat-adding-table-column">
|
||||
<xsl:param name="table:table-column" />
|
||||
<xsl:param name="numberColumnsRepeated" />
|
||||
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$numberColumnsRepeated > 1">
|
||||
<!-- writes an entry of a column in the columns-variable -->
|
||||
<xsl:copy-of select="." />
|
||||
<!-- repeat calling this method until all elements written out -->
|
||||
<xsl:call-template name="repeat-adding-table-column">
|
||||
<xsl:with-param name="numberColumnsRepeated" select="$numberColumnsRepeated - 1" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- writes an entry of a column in the columns-variable -->
|
||||
<xsl:copy-of select="." />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!--debugEnabled-START-->
|
||||
<!-- giving out the 'allColumnStyle' variable:
|
||||
For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
|
||||
In case of 'column-hidden-flag' attribute the text 'Column is hidden is given out.-->
|
||||
<!-- current node is a table:table -->
|
||||
<xsl:template name="table-debug-allTableColumns">
|
||||
<xsl:param name="allTableColumns" />
|
||||
|
||||
<!-- debug output as table summary attribut in html -->
|
||||
<xsl:attribute name="summary">
|
||||
<xsl:call-template name="table-debug-column-out">
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
<!-- debug output to console -->
|
||||
<xsl:message>
|
||||
<xsl:call-template name="table-debug-column-out">
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
</xsl:call-template>
|
||||
</xsl:message>
|
||||
</xsl:template>
|
||||
|
||||
<!-- current node is a table:table -->
|
||||
<xsl:template name="table-debug-column-out">
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:text>
|
||||
DebugInformation: For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
|
||||
In case of table:visibility attribute unequal 'visible' the 'column is hidden' no text is given out.
|
||||
</xsl:text>
|
||||
<xsl:for-each select="$allTableColumns/table:table-column">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@table:visibility = 'collapse' or @table:visibility = 'filter' ">
|
||||
<xsl:text> </xsl:text><xsl:value-of select="@table:style-name" /><xsl:text>column is hidden</xsl:text><xsl:text>
|
||||
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text> </xsl:text><xsl:value-of select="@table:style-name" /><xsl:text> </xsl:text><xsl:value-of select="@table:default-cell-style-name" /><xsl:text>
|
||||
</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
<!--debugEnabled-END-->
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,208 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--***********************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
***********************************************************-->
|
||||
|
||||
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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">
|
||||
|
||||
|
||||
<xsl:param name="rowElement" select="'tr'" />
|
||||
|
||||
<!-- ********************************** -->
|
||||
<!-- *** write repeating table rows *** -->
|
||||
<!-- ********************************** -->
|
||||
|
||||
<!-- current node is a table:table -->
|
||||
<xsl:template name="create-table-rows">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allVisibleTableRows" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
|
||||
<!-- Some Office Calc documents simulate a background by repeating one of the later cells until end of used space
|
||||
(The value of "table:number-columns-repeated" is enourmous). Writing out all these cells would be fatal in time
|
||||
and output size. Therefore, this global variable shows us the longest row with content. -->
|
||||
<xsl:variable name="maxRowLength" select="count($allTableColumns/table:table-column)" />
|
||||
<xsl:if test="$debugEnabled">
|
||||
<xsl:message>maxRowLength: <xsl:value-of select="$maxRowLength" /></xsl:message>
|
||||
<xsl:call-template name="table-debug-allTableColumns">
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
|
||||
<!-- a table is a table header, when it has a "table:table-header-rows" ancestor -->
|
||||
<xsl:variable name="tableDataType">
|
||||
<xsl:choose>
|
||||
<xsl:when test="ancestor::table:table-header-rows">
|
||||
<xsl:text>th</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>td</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<!-- removes repetition of rows, most probably done for background emulating -->
|
||||
<xsl:for-each select="$allVisibleTableRows">
|
||||
<xsl:choose>
|
||||
<xsl:when test="(last() or (last() - 1)) and @table:number-rows-repeated > 99">
|
||||
<xsl:call-template name="repeat-write-row">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="numberRowsRepeated" select="1" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="repeat-write-row">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="numberRowsRepeated" select="@table:number-rows-repeated" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="repeat-write-row">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="numberRowsRepeated" select="1" />
|
||||
<xsl:param name="maxRowLength" />
|
||||
<xsl:param name="tableDataType" />
|
||||
|
||||
<xsl:choose>
|
||||
<!-- write an entry of a row and repeat calling this method until all elements are written out -->
|
||||
<xsl:when test="$numberRowsRepeated > 1 and table:table-cell">
|
||||
<xsl:call-template name="write-row">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
|
||||
<!-- NOTE: take variable from the output of repeated write-row and iterate giving out the variable -->
|
||||
<xsl:call-template name="repeat-write-row">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="numberRowsRepeated" select="$numberRowsRepeated - 1" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<!-- write a single entry of a row -->
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="write-row">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="add-table-row-attributes">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<!-- writing the style of the row -->
|
||||
<xsl:if test="@table:style-name">
|
||||
<xsl:call-template name='add-style-properties'>
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="write-row">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="maxRowLength" />
|
||||
<xsl:param name="tableDataType" />
|
||||
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="{$rowElement}">
|
||||
<xsl:call-template name='add-table-row-attributes'>
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
|
||||
<xsl:if test="$debugEnabled">
|
||||
<xsl:message>'tr' element has been added!</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:apply-templates select="table:table-cell">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:apply-templates>
|
||||
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- **************************** -->
|
||||
<!-- *** HELPER: table styles *** -->
|
||||
<!-- **************************** -->
|
||||
|
||||
<xsl:template name="add-style-properties">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="node-position" />
|
||||
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="translate(@table:style-name, '. %()/\+', '')" />
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,584 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--***********************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
***********************************************************-->
|
||||
|
||||
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://xml.apache.org/xslt/java" xmlns:sxg="http://www.jclark.com/xt/java/org.openoffice.xslt.OOoMasterDocument" xmlns:common="http://exslt.org/common" xmlns:xt="http://www.jclark.com/xt" xmlns:xalan="http://xml.apache.org/xalan" 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 java sxg xt common xalan">
|
||||
|
||||
<!-- ****************************** -->
|
||||
<!-- *** Table of Content *** -->
|
||||
<!-- ****************************** -->
|
||||
|
||||
<xsl:param name="currentChildContentRef" />
|
||||
<xsl:param name="contentTableHeadings" />
|
||||
<xsl:param name="contentTableURL" />
|
||||
<xsl:template match="text:table-of-content">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="text:index-body">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="parent::table-of-content and */text:tab[1] or */*/text:tab[1]">
|
||||
<xsl:call-template name="createIndexBodyTable">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:index-title" mode="content-table">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="createIndexBodyTable">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:variable name="allStyleTabStops-RTF">
|
||||
<xsl:element name="style:tab-stops">
|
||||
<xsl:call-template name="get-tab-stops">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="styleName" select="current()/@text:style-name"/>
|
||||
|
||||
<!--
|
||||
Currently only the style of text:index-body is recognized, but not of a paragraph child containing the text:tab element!
|
||||
<xsl:with-param name="styleName" select="descendant-or-self::*/@text:style-name"/>
|
||||
|
||||
The column width needs to be tabstop plus fo:margin-left paragraph-properties
|
||||
-->
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:variable>
|
||||
<xsl:element namespace="{$namespace}" name="table">
|
||||
|
||||
<xsl:attribute name="border">0</xsl:attribute>
|
||||
<xsl:attribute name="cellspacing">0</xsl:attribute>
|
||||
<xsl:attribute name="cellpadding">0</xsl:attribute>
|
||||
<xsl:if test="parent::*/@text:style-name">
|
||||
<!-- parent as index:body has no style -->
|
||||
<xsl:variable name="value" select="$globalData/all-doc-styles/style[@style:name = current()/parent::*/@text:style-name]/*/@style:rel-width"/>
|
||||
<xsl:if test="$value">
|
||||
<xsl:attribute name="width">
|
||||
<xsl:value-of select="$value"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="translate(parent::*/@text:style-name, '.,;: %()[]/\+', '_____________')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="colgroup">
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="create-col-element">
|
||||
<xsl:with-param name="lastNodePosition" select="count(common:node-set($allStyleTabStops-RTF)/style:tab-stops/style:tab-stop)"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="common:node-set($allStyleTabStops-RTF)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="create-col-element">
|
||||
<xsl:with-param name="lastNodePosition" select="count(xalan:nodeset($allStyleTabStops-RTF)/style:tab-stops/style:tab-stop)"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="xalan:nodeset($allStyleTabStops-RTF)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="create-col-element">
|
||||
<xsl:with-param name="lastNodePosition" select="count(xt:node-set($allStyleTabStops-RTF)/style:tab-stops/style:tab-stop)"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="xt:node-set($allStyleTabStops-RTF)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:element>
|
||||
|
||||
<!-- add table data -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:apply-templates mode="content-table">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="common:node-set($allStyleTabStops-RTF)"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:apply-templates mode="content-table">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="xalan:nodeset($allStyleTabStops-RTF)"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:apply-templates mode="content-table">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="xt:node-set($allStyleTabStops-RTF)"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- ************************************************ -->
|
||||
<!-- *** Create Table for Content Table Paragraph *** -->
|
||||
<!-- ************************************************ -->
|
||||
|
||||
<!-- Usually the paragraph in a content-table are ordered by tab-stops, which can not be displayed correctly by XHTML/CSS
|
||||
Therefore they will be simulated by a table -->
|
||||
<xsl:template match="text:p" mode="content-table">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:param name="allStyleTabStops"/>
|
||||
|
||||
<!-- all elements before the first tabStop -->
|
||||
<xsl:variable name="testNo-RTF">
|
||||
<xsl:apply-templates select="node()" mode="cell-content"/>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:variable name="tabNodePositions" select="common:node-set($testNo-RTF)"/>
|
||||
<xsl:element namespace="{$namespace}" name="tr">
|
||||
<xsl:call-template name="create-td-elements">
|
||||
<xsl:with-param name="lastNodePosition" select="count($allStyleTabStops/style:tab-stops/style:tab-stop)"/>
|
||||
<xsl:with-param name="position" select="1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:variable name="tabNodePositions" select="xalan:nodeset($testNo-RTF)"/>
|
||||
<xsl:element namespace="{$namespace}" name="tr">
|
||||
<xsl:call-template name="create-td-elements">
|
||||
<xsl:with-param name="lastNodePosition" select="count($allStyleTabStops/style:tab-stops/style:tab-stop)"/>
|
||||
<xsl:with-param name="position" select="1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:variable name="tabNodePositions" select="xt:node-set($testNo-RTF)"/>
|
||||
<xsl:element namespace="{$namespace}" name="tr">
|
||||
<xsl:call-template name="create-td-elements">
|
||||
<xsl:with-param name="lastNodePosition" select="count($allStyleTabStops/style:tab-stops/style:tab-stop)"/>
|
||||
<xsl:with-param name="position" select="1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Gathering all style:tab-stops from a style-hierarchy as siblings -->
|
||||
<xsl:template name="get-tab-stops">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:param name="styleName"/>
|
||||
<xsl:variable name="tabStyle" select="key('styles', $styleName)"/>
|
||||
|
||||
<xsl:if test="$tabStyle/*/style:tab-stops/style:tab-stop/@style:position">
|
||||
<xsl:for-each select="$tabStyle/*/style:tab-stops/style:tab-stop">
|
||||
<xsl:copy-of select="."/>
|
||||
</xsl:for-each>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="$tabStyle/@style:parent-style-name">
|
||||
<xsl:call-template name="get-tab-stops">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="styleName" select="$tabStyle/@style:parent-style-name"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="create-col-element">
|
||||
<xsl:param name="lastNodePosition"/>
|
||||
<xsl:param name="allStyleTabStops"/>
|
||||
|
||||
<xsl:for-each select="$allStyleTabStops/style:tab-stops/style:tab-stop">
|
||||
<xsl:element namespace="{$namespace}" name="col">
|
||||
<xsl:attribute name="style">
|
||||
<xsl:text>width: </xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(@style:position, 'cm')">
|
||||
<xsl:call-template name="create-cell-width">
|
||||
<xsl:with-param name="width" select="number(substring-before(@style:position,'cm'))"/>
|
||||
<xsl:with-param name="unit" select="'cm'"/>
|
||||
<xsl:with-param name="position" select="position() - 1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(@style:position, 'in')">
|
||||
<xsl:call-template name="create-cell-width">
|
||||
<xsl:with-param name="width" select="number(substring-before(@style:position,'in'))"/>
|
||||
<xsl:with-param name="unit" select="'in'"/>
|
||||
<xsl:with-param name="position" select="position() - 1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(@style:position, 'ch')">
|
||||
<xsl:call-template name="create-cell-width">
|
||||
<xsl:with-param name="width" select="number(substring-before(@style:position,'ch'))"/>
|
||||
<xsl:with-param name="unit" select="'ch'"/>
|
||||
<xsl:with-param name="position" select="position() - 1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(@style:position, 'pt')">
|
||||
<xsl:call-template name="create-cell-width">
|
||||
<xsl:with-param name="width" select="number(substring-before(@style:position,'pt'))"/>
|
||||
<xsl:with-param name="unit" select="'pt'"/>
|
||||
<xsl:with-param name="position" select="position() - 1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:for-each>
|
||||
|
||||
</xsl:template>
|
||||
<!--
|
||||
Scenarios tabstops
|
||||
|
||||
1) style:type of style:tab-stop is 'right' and earlier tabStop is not right
|
||||
-> Earlier text-nodes and following text-nodes, will be put into an inner table, with two TD first aligned left, with proceding textnodes, the latter aligned right.
|
||||
|
||||
2) style:type is 'right' and earlier tabStop is right
|
||||
-> following text-nodes, will be put into a right aligned TD
|
||||
|
||||
3) style:type is 'non-right' and earlier tabStop 'non-right' as well
|
||||
-> put the preceding tab stops into a TD (left aligned is default)
|
||||
|
||||
4) first style:type would have no right preceding tabStop
|
||||
-> works well with first sceanrios 1 and 3
|
||||
|
||||
5) last style:type would be a special case, if it would be left aligned, but this won't happen in our case.. :D
|
||||
|
||||
Scenarios unmatched:
|
||||
- text:styleposition 'center' will not be matched in our case (effort for nothing), there will be only 'right' and not 'right'
|
||||
- If the last tabStop is not from text:stylepostion 'right', the length of the last cell is undefined and a document length must be found.
|
||||
Not happens in our master document case. Also the algorithm below would have to be expanded (cp. scenario 5).
|
||||
|
||||
-->
|
||||
<xsl:template name="create-td-elements">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:param name="lastNodePosition"/>
|
||||
<xsl:param name="position"/>
|
||||
<xsl:param name="allStyleTabStops"/>
|
||||
<xsl:param name="tabNodePositions"/>
|
||||
|
||||
<xsl:variable name="currentTabStop" select="$allStyleTabStops/style:tab-stops/style:tab-stop[$position]"/>
|
||||
<xsl:variable name="earlierTabStop" select="$allStyleTabStops/style:tab-stops/style:tab-stop[$position - 1]"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="not($currentTabStop/@style:position) and not($earlierTabStop/@style:position)">
|
||||
<!-- in case no TAB STOP is being set -->
|
||||
<xsl:element namespace="{$namespace}" name="td">
|
||||
<xsl:element namespace="{$namespace}" name="p">
|
||||
<xsl:if test="$position = 1">
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates mode="content-table">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$currentTabStop/@style:type = 'right'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$earlierTabStop/@style:type = 'right'">
|
||||
<!--
|
||||
2) style:type is 'right' and earlier tabStop is right
|
||||
-> following text-nodes, will be put into a right aligned TD -->
|
||||
<xsl:element namespace="{$namespace}" name="td">
|
||||
<xsl:attribute name="style">
|
||||
<xsl:text>align: right</xsl:text>
|
||||
</xsl:attribute>
|
||||
<xsl:element namespace="{$namespace}" name="p">
|
||||
<xsl:if test="$position = 1">
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:call-template name="grab-cell-content-before-tab-stop">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="endingTabStopPosition" select="$position + 1"/>
|
||||
<xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:element namespace="{$namespace}" name="td">
|
||||
<xsl:element namespace="{$namespace}" name="p">
|
||||
<xsl:if test="$position = 1">
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:call-template name="grab-cell-content-before-tab-stop">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="endingTabStopPosition" select="$position"/>
|
||||
<xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$earlierTabStop/@style:type = 'right'"></xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!--
|
||||
3) style:type is 'non-right' and earlier tabStop 'non-right' as well
|
||||
-> put the preceding tab stops into a TD (left aligned is default) -->
|
||||
<xsl:element namespace="{$namespace}" name="p">
|
||||
<xsl:if test="$position = 1">
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:element namespace="{$namespace}" name="td">
|
||||
<xsl:call-template name="grab-cell-content-before-tab-stop">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="endingTabStopPosition" select="$position"/>
|
||||
<xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:if test="$position != $lastNodePosition">
|
||||
<xsl:call-template name="create-td-elements">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
|
||||
<xsl:with-param name="position" select="$position + 1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="grab-cell-content-before-tab-stop">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:param name="endingTabStopPosition"/>
|
||||
<xsl:param name="tabNodePositions"/>
|
||||
<xsl:param name="lastNodePosition"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$endingTabStopPosition = 1">
|
||||
<xsl:apply-templates mode="content-table" select="node()[position() < $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]]">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:when test="$endingTabStopPosition > $lastNodePosition">
|
||||
<xsl:apply-templates mode="content-table" select="node()[position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="nodesOfNextColumn" select="node()[position() < $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]][position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$nodesOfNextColumn != ''">
|
||||
<xsl:apply-templates mode="content-table" select="$nodesOfNextColumn">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates mode="content-table">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- As the span width will be mapped to column width, the preceding span widths have to be substracted -->
|
||||
<xsl:template name="create-cell-width">
|
||||
<xsl:param name="width"/>
|
||||
<xsl:param name="unit"/>
|
||||
<xsl:param name="position"/>
|
||||
<xsl:param name="allStyleTabStops"/>
|
||||
|
||||
<xsl:choose>
|
||||
<!-- beyond second width -->
|
||||
<xsl:when test="$position > 1">
|
||||
<xsl:call-template name="create-cell-width">
|
||||
<xsl:with-param name="width" select="$width - number(substring-before($allStyleTabStops/style:tab-stops/style:tab-stop[$position]/@style:position,$unit))"/>
|
||||
<xsl:with-param name="unit" select="$unit"/>
|
||||
<xsl:with-param name="position" select="$position - 1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<!-- second width -->
|
||||
<xsl:when test="$position = 1">
|
||||
<xsl:value-of select="concat($width - number(substring-before($allStyleTabStops/style:tab-stops/style:tab-stop[$position]/@style:position,$unit)), $unit)"/>
|
||||
</xsl:when>
|
||||
<!-- first width -->
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat($width, $unit)"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- ************************************** -->
|
||||
<!-- CREATION OF A CONTENT TABLE LINK -->
|
||||
<!-- ************************************** -->
|
||||
|
||||
<xsl:key name="bookmark" match="text:bookmark | text:bookmark-start" use="@text:name"/>
|
||||
|
||||
<!-- content table link -->
|
||||
<xsl:template match="text:a" mode="content-table">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:variable name="name" select="substring(@xlink:href,2)"/>
|
||||
|
||||
<xsl:variable name="text">
|
||||
<xsl:choose>
|
||||
<!-- heuristic assumption that first in a content table row, there is numbering (if at all) and than the text,
|
||||
furthermore that a tab will separate the to be neglected page number -->
|
||||
<xsl:when test="text:tab">
|
||||
<xsl:call-template name="write-text-without-line-numbers">
|
||||
<xsl:with-param name="textCount" select="count(text())"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="text()"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<!-- REFERENCE HANDLING - HREF -->
|
||||
<xsl:element namespace="{$namespace}" name="a">
|
||||
<xsl:attribute name="href">
|
||||
<xsl:text>#</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="key('bookmark',$name)">
|
||||
<xsl:value-of select="$name"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select='concat("a_", translate(normalize-space($text), "
&<>.,;: %()[]/\+", "_______________________________"))'/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
<xsl:value-of select="$text"/>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Heuristic: write out text separated by elements, leaving the last number out (mostly text number) -->
|
||||
<xsl:template name="write-text-without-line-numbers">
|
||||
<xsl:param name="textCount"/>
|
||||
<xsl:param name="textNodeNumber" select="1"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$textCount > $textNodeNumber">
|
||||
<xsl:value-of select="text()[$textNodeNumber]"/>
|
||||
<xsl:call-template name="write-text-without-line-numbers">
|
||||
<xsl:with-param name="textCount" select="$textCount"/>
|
||||
<xsl:with-param name="textNodeNumber" select="$textNodeNumber + 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:if test="not(number(text()[$textNodeNumber]) > -1)">
|
||||
<xsl:value-of select="text()[$textNodeNumber]"/>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:s" mode="content-table">
|
||||
<xsl:call-template name="write-breakable-whitespace">
|
||||
<xsl:with-param name="whitespaces" select="@text:c"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<!-- ******************** -->
|
||||
<!-- *** Common Rules *** -->
|
||||
<!-- ******************** -->
|
||||
|
||||
<xsl:template match="*" mode="content-table">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:apply-templates select=".">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="*" mode="cell-content">
|
||||
<xsl:if test="name() = 'text:tab' or *[name() = 'text:tab']">
|
||||
<xsl:element name="tab-stop-node-position" namespace="">
|
||||
<xsl:value-of select="position()"/>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text()" mode="content-table">
|
||||
<!-- Heuristic to remove page numbers (useless in HTML) in the content table
|
||||
usually after a tab -->
|
||||
<xsl:if test="name(preceding-sibling::*[1]) != 'text:tab' and not(number() > -1)">
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
Reference in New Issue
Block a user