Subject: [xsl] Re: Transformation of hierarchy, changing levels, and... back From: Marcin Miłkowski <milek_pl@xxxxx> Date: Wed, 03 Aug 2005 17:03:49 +0200 |
sorry for being imprecise. I tried to use my abbreviated notation and that was a big mistake. However, it seems to me I found a solution.
Are the parenthetical expressions meant to appear in the output document or are they there to illustrate the relationship between the elements in the input document and the elements in the output document?
Cheers, Marcin
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
doctype-system="http://www.oasis-open.org/committees/xliff/documents/xliff.dtd"/> <xsl:param name="Src">en-US</xsl:param> <xsl:param name="Trg"></xsl:param>
<xsl:template match="TRADOStag"> <xliff version="1.0" xml:lang="en"> <xsl:element name="file"> <xsl:attribute name="original">TMX-file.tmx</xsl:attribute> <xsl:attribute name="source-language"> <xsl:value-of select="$Src"/> </xsl:attribute> <xsl:attribute name="target-language"> <xsl:value-of select="$Trg"/> </xsl:attribute> <xsl:attribute name="datatype">TTX document</xsl:attribute> <header> <skl> <external-file href="skeleton.skl" /> </skl> </header> <xsl:choose> <xsl:when test="//Tu"/> <xsl:otherwise> <xsl:message terminate="yes"> Error: This TTX file is not bilingual, cannot proceed! You have to use a monolingual filter with a segmenter. </xsl:message> </xsl:otherwise> </xsl:choose> <body> <xsl:apply-templates/> </body> </xsl:element> </xliff> </xsl:template>
<xsl:template match="//Tu"> <xsl:element name="trans-unit"> <xsl:attribute name="id"> <xsl:value-of select="generate-id()"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template>
<xsl:template match="//Tuv"> <xsl:if test="@Lang=$Src"> <source> <xsl:apply-templates/> </source> </xsl:if> <xsl:if test='@Lang=$Trg'> <xsl:element name="target"> <xsl:apply-templates/> </xsl:element> </xsl:if> <xsl:if test='@Lang!=$Src and @Lang!=$Trg'> <xsl:element name="alt-trans"> <xsl:element name="target"> <xsl:attribute name="xml:lang"><xsl:value-of select="@lang"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:element> </xsl:if> </xsl:template>
<xsl:template match="//Tu/Tuv/df"> <xsl:element name="g"> <xsl:attribute name="id"> <xsl:value-of select="generate-id()"/> </xsl:attribute> <xsl:attribute name="ts"> <xsl:for-each select="@*"> <xsl:text>x-df-contents:</xsl:text> <xsl:value-of select="name(.)"/> <xsl:text>=</xsl:text><xsl:value-of select="."/> <xsl:text>;</xsl:text> </xsl:for-each> </xsl:attribute> </xsl:element> <xsl:apply-templates/> <xsl:element name="g"> <xsl:attribute name="ts">x-skl-snip</xsl:attribute> <xsl:attribute name="id"> <xsl:number count="Tu/Tuv/node()" level="any"/> </xsl:attribute> </xsl:element> <xsl:value-of select="./text()"/> <xsl:element name="g"> <xsl:attribute name="id"> <xsl:value-of select="generate-id()"/> </xsl:attribute> </xsl:element> </xsl:template>
<xsl:template match="//Tu/Tuv/ut | //Tu/Tuv/df/ut"> <xsl:element name="ph"> <xsl:attribute name="id"> <xsl:value-of select="generate-id()"/> </xsl:attribute> <xsl:value-of select="./text()"/> </xsl:element> </xsl:template>
<xsl:template match="//Tu/Tuv/text()"> <xsl:element name="g"> <xsl:attribute name="ts">x-skl-snip</xsl:attribute> <xsl:attribute name="id"> <xsl:number count="Tu/Tuv/node()" level="any"/> </xsl:attribute> </xsl:element> <xsl:value-of select="."/> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] xsl:key function help, Michael Kay | Thread | [xsl] Problems with document() [PHP, Phillip Oldham |
[xsl] xsl:key function help, David Preuss | Date | Re: [xsl] xsl:key function help, Joris Gillis |
Month |