XSLT_TAO/filtres_TMX_pour_Calc/TMX-export.xsl

60 lines
2.7 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!-- Dominique Meeùs, created 1-10-2013, version 0.9.
XSLT transformation of an Open Document Format spreadsheet in two columns
into a TMX translation memory exchange file.
Filter to install as an export filter for LibreOffice Calc. -->
<!-- Copyright 2013 Dominique Meeùs.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
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"
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
exclude-result-prefixes="office table text">
<!-- Namespaces needed to access parts of the document -->
<xsl:output method = "xml" indent = "yes" encoding = "UTF-8" omit-xml-declaration = "no"/>
<xsl:template match="/">
<tmx version="1.4">
<header
creationtool="TMX-export for LibreOffice"
creationtoolversion="0.9"
segtype="sentence"
o-tmf="application/vnd.oasis.opendocument.spreadsheet"
adminlang="fr-BE"
srclang="nl-BE"
datatype="plaintext">
</header>
<!-- Todo : get the language from Calc, if any, or from a dialog, if LibreOffice allows,
to set the srclang of the header and the xml:lang of the tuv. -->
<body>
<xsl:for-each select="//table:table-row">
<tu>
<xsl:for-each select="table:table-cell">
<xsl:choose>
<xsl:when test="position()=1">
<tuv xml:lang="nl-BE">
<seg><xsl:value-of select="text:p"/></seg>
</tuv>
</xsl:when>
<xsl:when test="position()=2">
<tuv xml:lang="fr-BE">
<seg><xsl:value-of select="text:p"/></seg>
</tuv>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</tu>
</xsl:for-each>
</body>
</tmx>
</xsl:template>
</xsl:stylesheet>