Ajouter la version avec modèles qui corrige le dédoublement d'éléments

This commit is contained in:
Philippe Tourigny 2023-04-22 12:50:09 +09:00
parent 3610bd08f4
commit 55f63ec4ef

View File

@ -5,7 +5,7 @@
Filter to install as an export filter for LibreOffice Calc. -->
<!-- Dominique Meeùs, modified 21-5-2020, version 0.92.
Hardcoded languages of the columns are : nl-BE, fr-BE, de-DE, en-GB, es-ES. -->
<!-- Philippe Tourigny, modified 12-9-2022, version 0.94
<!-- Philippe Tourigny, modified 12-9-2022, version 0.95
Enable the filter to read the language code from the first column
in each row. Also, add a SYSTEM DOCTYPE declaration to the output
XML file. -->
@ -27,7 +27,7 @@
exclude-result-prefixes="office table text">
<!-- Namespaces needed to access parts of the document -->
<!-- Version 0.94: Add a SYSTEM DOCTYPE to output -->
<!-- Version 0.93: Add a SYSTEM DOCTYPE to output -->
<xsl:output method = "xml" indent = "yes" encoding = "UTF-8"
doctype-system="tmx14.dtd" omit-xml-declaration = "no"/>
@ -52,7 +52,7 @@
<header>
<xsl:attribute name="creationtool">TMX-export for LibreOffice</xsl:attribute>
<xsl:attribute name="creationtoolversion">0.94</xsl:attribute>
<xsl:attribute name="creationtoolversion">0.95</xsl:attribute>
<xsl:attribute name="segtype">sentence</xsl:attribute>
<xsl:attribute name="o-tmf">application/vnd.oasis.opendocument.spreadsheet</xsl:attribute>
<xsl:attribute name="adminlang">
@ -69,29 +69,28 @@
easier to modify and maintain. -->
<body>
<!-- Call the template to insert <tu> elements -->
<xsl:apply-templates select="//table:table"/>
<xsl:apply-templates select="//table:table-row[position()>1]"/>
</body>
</tmx>
</xsl:template>
<!-- Templates to populate the <tu> and <tuv> elements-->
<!-- Template for <tu> elements:
Loop through each row, skipping the first one. -->
<!-- Template to insert the <tu> elements:
Loop through each row, skipping the first one.
<xsl:template match="table:table">
<xsl:for-each select="table:table-row">
<tu>
<xsl:apply-templates select="//table:table-row[position()>1]"/>
</tu>
</xsl:for-each>
</xsl:template>
</xsl:template> -->
<!-- Template for the <tuv> elements:
Loop through each cell in the row, and assign the value
of the language for that column to the xml:lang attribute.
After that, add the <seg> element and populated it with the
text in the current cell. -->
<!-- Template to build the <tu> and <tuv> elements:
Within each <tu>, loop through the celsl in the row, and
assign the value of the language for that column to the
xml:lang attribute.
After that, add the <seg> element and populated it with
the text in the current cell. -->
<xsl:template match="table:table-row[position()>1]">
<tu>
<xsl:for-each select="table:table-cell">
<xsl:variable name="currentLang"
select="//table:table/table:table-row[1]/table:table-cell"/>
@ -108,6 +107,8 @@
</tuv>
</xsl:if>
</xsl:for-each>
</tu>
</xsl:template>
</xsl:stylesheet>