优化项目结构、优化 maven 结构

This commit is contained in:
chenkailing
2021-02-10 00:58:13 +08:00
parent 28d3e05ca9
commit 2542a24675
3610 changed files with 77 additions and 180 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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 &gt; 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>

View File

@@ -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 &gt; 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>