[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: For each child, create a new parent node including

Subject: Re: For each child, create a new parent node including only that child
From: "Manuel Souto Pico terminolator@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 28 Aug 2019 11:02:55 -0000
 Re: For each child
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@xxxxxxxxx> escreveu no dia quarta,
28/08/2019 C (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.dt
d
> ">
>
>       <tu>
>          <tuv xml:lang="en-ZZ">
>             <seg>Moving Around and Tracking Progress</seg>
>          </tuv>
>          <tuv xml:lang="pt-BR">
>             <seg>MovimentaC'C#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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.