A quick update.
I think I am closer in this version:
https://xsltfiddle.liberty-development.net/6rewNxx/4. The second problem is
fixed in it, the other two problems remain.
I keep working on it, any tips are most welcome.
Cheers, Manuel
Manuel Souto Pico <terminolator(_at_)gmail(_dot_)com> escreveu no dia quarta,
28/08/2019 à(s) 12:52:
Dear all,
What I am trying to do should be quite easy but I need some help.
Here you can see the kind of input I have and my first attempt:
https://xsltfiddle.liberty-development.net/6rewNxx
So:
- tu
-- tuv en (1)
-- tuv pt (1)
-- tuv pt (2)
-- tuv pt (n)
In that input you can see that a tu node might have one source language
tuv child and more than one target-language tuv children, such as the one
with source text "Moving Around and Tracking Progress".
The expect output is to have only one tuv child per tu node:
- tu
-- tuv en (1)
-- tuv pt (1)
- tu
-- tuv en (1)
-- tuv pt (2)
- tu
-- tuv en (1)
-- tuv pt (1)
Something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tmx SYSTEM "
https://raw.githubusercontent.com/moiatgit/omegat/master/src/schemas/tmx14.dtd
">
<tu>
<tuv xml:lang="en-ZZ">
<seg>Moving Around and Tracking Progress</seg>
</tuv>
<tuv xml:lang="pt-BR">
<seg>Movimentação e monitoramento de progresso</seg>
</tuv>
</tu>
<tu>
<tuv xml:lang="en-ZZ">
<seg>Moving Around and Tracking Progress</seg>
</tuv>
<tuv xml:lang="pt-BR">
<seg>Movendo-se e Monitorando o seu progresso</seg>
</tuv>
</tu>
<tu>
<tuv xml:lang="en-ZZ">
<seg>Moving Around and Tracking Progress</seg>
</tuv>
<tuv xml:lang="pt-BR">
<seg>Movendo-se e Monitorando seu progresso</seg>
</tuv>
</tu>
In other words, unmerge the tu node, keeping always the same source text.
My stylesheet is:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="body">
<xsl:copy>
<xsl:for-each select='tu/tuv[@xml:lang="pt-BR"]'>
<tu>
<xsl:copy-of
select='ancestor::tuv[@xml:lang="en-ZZ"]'/>
<xsl:copy-of select="."/>
</tu>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
It has several problems:
1. The tmx root node is missing in my output
2. The source language (en-ZZ) does not appear in my output
3. It is specific for pt-BR, but the tag for the target language (i.e. for
the multiple children) could be any -- the stylesheet should be generic
(target-language agnostic).
I don't have a preference about the XSLT version, I think there are
non-commercial (free to use) Saxon processors for all three.
Hopefully somebody can help me find solutions or point me in the right
direction. Thanks in advance.
Cheers, Manuel
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--