xsl-list
[Top] [All Lists]

Transformation of hierarchy, changing levels, and... back

2005-08-02 08:13:20
hi,

I've been trying to make some transformation from a structure:

<Tu>
        <Tuv>
                @Lang
                some text1
                <df>some text2</df>
                <ut>some optional text</ut>
                some text
                <ut>some more text</ut>
                and some text
        </Tuv>
        <Tuv>
                @Lang
                some text
                <df>
                some text
                </df>
                <ut>some optional text</ut>
                some text
                <ut>some more text</ut>
                and some text
        </Tuv>
</Tu>

to a structure

<trans-unit>      (=Tu)
        @id
        <source> (=Tu/Tuv(_at_)Lang=$blabla)

                some text1
                <g(_at_)id@barfoo/>       (<df>)
                some text2
                <g(_at_)id@foobar/>       (</df>)
                <ph(_at_)id>some optional text</ph>(=ut)
                some text
                <ph(_at_)id>some more text</ut>
                and some text
        </source>
        
        <target> (=Tu/Tuv(_at_)Lang=$foobar)
                some text1
                <g(_at_)id@barfoo/>       (<df>)
                some text2
                <g(_at_)id@foobar/>       (</df>)
                <ph(_at_)id>some optional text</ph>(=ut)
                some text
                <ph(_at_)id>some more text</ut>
                and some text
        </target>
</trans-unit>

I tried to match //Tu, and then use for-each to match all Tuv[1]/ut and Tuv[2]/ut. This approach turned quite difficult because I had to insert ut at exactly the same position in source as it was in Tuv[1]. Probably I should use more templates and match //Tu/Tuv or something like that, but I wouldn't know how to close the trans-unit tag (is there a way to check if this Tuv is Tu/Tuv[1] or Tu/Tuv[2]?). Additionally, I would need to produce a second file with ids replacing all text between tags in Tu/Tuv[1](_at_)Lang=foobar and Tu/Tuv[2](_at_)lLang=barfoo(_dot_) (So the text must be uniquely numbered, or indexed in the other file). The third step would be to backconvert the transformed files into a source one.

Any ideas what method would be the best in this case? All help very appreciated.

Best regards,
        Marcin Milkowski

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>