Déclarer les variables globalement et déplacer l'élément racine

This commit is contained in:
Philippe Tourigny 2023-06-03 12:44:38 +09:00
parent 8af606bd0f
commit b0a6f0e6e1

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Dominique Meeùs, created 30-9-2013, version 0.9.
XSLT transformation of a TMX translation memory exchange file
into an Open Document Format spreadsheet in two columns.
@ -21,6 +20,18 @@
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program.
If not, see http://www.gnu.org/licenses/. -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Define variables used to identify the languages
In a TMX with three or more languages, all translation unit
(<tuv>) elements are assumed to contain the same number of
languages, and the first <tu> is used to identify them. -->
<!-- Todo: Identify the <tu> with the largest highest number of <tuv> elements to identify all languages in a TMX file with more languages in some <tu> elements than others. -->
<xsl:variable name="firstTU" select="tmx/body/tu[1]"/>
<xsl:variable name="numLangs" select="count($firstTU/tuv)"/>
<xsl:template match="/">
<office:document-content
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
@ -31,12 +42,6 @@
office:version="1.0">
<office:automatic-styles>
<!-- PTable properties -->
<style:style style:name="ta1" style:family="table"
style:master-page-name="Default">
<style:table-properties table:display="true"
style:writing-mode="lr-tb"/>
</style:style>
<!-- Column properties (for all languages) -->
<style:style style:name="co1" style:family="table-column">
@ -67,19 +72,11 @@
<!-- Style for cells with the segment text -->
<style:style style:name="ce2" style:family="table-cell"
style:parent-style-name="Default">
<style:table-cell-properties fo:wrap-option="wrap"/>
<style:table-cell-properties fo:wrap-option="wrap"
style:vertical-align="top"/>
</style:style>
</office:automatic-styles>
<!-- Define variables used to identify the languages
In a TMX with three or more languages. All translation unit
(<tuv>) elements are assumed to contain the same number of
languages, and the first <tu> is used to identify them. -->
<!-- Todo: Identify the <tu> with the largest highest number of <tuv> elements to identify all languages in a TMX file with more languages in some <tu> elements than others. -->
<xsl:variable name="firstTU" select="tmx/body/tu[1]"/>
<xsl:variable name="numLangs" select="count($firstTU/tuv)"/>
<office:body>
<office:spreadsheet>
<table:table table:style-name="ta1">