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
1 changed files with 18 additions and 17 deletions

View File

@ -5,10 +5,10 @@
Filter to install as an export filter for LibreOffice Calc. --> Filter to install as an export filter for LibreOffice Calc. -->
<!-- Dominique Meeùs, modified 21-5-2020, version 0.92. <!-- 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. --> 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 Enable the filter to read the language code from the first column
in each row. Also, add a SYSTEM DOCTYPE declaration to the output in each row. Also, add a SYSTEM DOCTYPE declaration to the output
XML file.--> XML file. -->
<!-- Copyright 2013, 2020 Dominique Meeùs, and 2022 Philippe Tourigny@. <!-- Copyright 2013, 2020 Dominique Meeùs, and 2022 Philippe Tourigny@.
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License under the terms of the GNU Lesser General Public License
@ -27,7 +27,7 @@
exclude-result-prefixes="office table text"> exclude-result-prefixes="office table text">
<!-- Namespaces needed to access parts of the document --> <!-- 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" <xsl:output method = "xml" indent = "yes" encoding = "UTF-8"
doctype-system="tmx14.dtd" omit-xml-declaration = "no"/> doctype-system="tmx14.dtd" omit-xml-declaration = "no"/>
@ -52,7 +52,7 @@
<header> <header>
<xsl:attribute name="creationtool">TMX-export for LibreOffice</xsl:attribute> <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="segtype">sentence</xsl:attribute>
<xsl:attribute name="o-tmf">application/vnd.oasis.opendocument.spreadsheet</xsl:attribute> <xsl:attribute name="o-tmf">application/vnd.oasis.opendocument.spreadsheet</xsl:attribute>
<xsl:attribute name="adminlang"> <xsl:attribute name="adminlang">
@ -69,29 +69,28 @@
easier to modify and maintain. --> easier to modify and maintain. -->
<body> <body>
<!-- Call the template to insert <tu> elements --> <!-- Call the template to insert <tu> elements -->
<xsl:apply-templates select="//table:table"/> <xsl:apply-templates select="//table:table-row[position()>1]"/>
</body> </body>
</tmx> </tmx>
</xsl:template> </xsl:template>
<!-- Templates to populate the <tu> and <tuv> elements--> <!-- Template to insert the <tu> elements:
Loop through each row, skipping the first one.
<!-- Template for <tu> elements:
Loop through each row, skipping the first one. -->
<xsl:template match="table:table"> <xsl:template match="table:table">
<xsl:for-each select="table:table-row"> <xsl:for-each select="table:table-row">
<tu>
<xsl:apply-templates select="//table:table-row[position()>1]"/> <xsl:apply-templates select="//table:table-row[position()>1]"/>
</tu>
</xsl:for-each> </xsl:for-each>
</xsl:template> </xsl:template> -->
<!-- Template for the <tuv> elements: <!-- Template to build the <tu> and <tuv> elements:
Loop through each cell in the row, and assign the value Within each <tu>, loop through the celsl in the row, and
of the language for that column to the xml:lang attribute. assign the value of the language for that column to the
After that, add the <seg> element and populated it with the xml:lang attribute.
text in the current cell. --> After that, add the <seg> element and populated it with
the text in the current cell. -->
<xsl:template match="table:table-row[position()>1]"> <xsl:template match="table:table-row[position()>1]">
<tu>
<xsl:for-each select="table:table-cell"> <xsl:for-each select="table:table-cell">
<xsl:variable name="currentLang" <xsl:variable name="currentLang"
select="//table:table/table:table-row[1]/table:table-cell"/> select="//table:table/table:table-row[1]/table:table-cell"/>
@ -108,6 +107,8 @@
</tuv> </tuv>
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
</tu>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>