Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Copy source to translation when type equals unfinished Copy source to translation when type equals unfinishedTo: NULL Date: 7/11/2008 2:13:00 AM Hi, I have the following XML file: <TS> <context> <name>ElementName</name> <message> <location line="16" filename="build/debug/xslt/ xml_ApplicationDefaults.cpp" /> <source>Application</source> <translation>Programm</translation> </message> <message> <location line="24" filename="build/debug/xslt/ xml_ElementsPaneLayout_PS.cpp" /> <source>Archive hierarchy</source> <translation type="unfinished" /> </message> <message> <location line="18" filename="build/debug/xslt/ xml_ElementsPaneLayout_PS.cpp" /> <source>Folder</source> <translation>Ordner</translation> </message> <message> <location line="28" filename="build/debug/xslt/ xml_ElementsPaneLayout_PS.cpp" /> <source>Job assembler</source> <translation type="unfinished" /> </message> <message> <location line="26" filename="build/debug/xslt/ xml_ElementsPaneLayout_PS.cpp" /> <source>Job dismantler</source> <translation>Jobs zerlegen</translation> </message> </context> </TS> To process this file in our translation environment I would need an XSL transformation that copies this file with the following change: whenever the attribute type of the element translation equals unfinished, I want the content of the element source copied to the element target. So the desired output would look like this: <TS> <context> <name>ElementName</name> <message> <location line="16" filename="build/debug/xslt/ xml_ApplicationDefaults.cpp" /> <source>Application</source> <translation>Programm</translation> </message> <message> <location line="24" filename="build/debug/xslt/ xml_ElementsPaneLayout_PS.cpp" /> <source>Archive hierarchy</source> <translation type="unfinished">Archive hierarchy</translation> </message> <message> <location line="18" filename="build/debug/xslt/ xml_ElementsPaneLayout_PS.cpp" /> <source>Folder</source> <translation>Ordner</translation> </message> <message> <location line="28" filename="build/debug/xslt/ xml_ElementsPaneLayout_PS.cpp" /> <source>Job assembler</source> <translation type="unfinished">Job assembler</translation> </message> <message> <location line="26" filename="build/debug/xslt/ xml_ElementsPaneLayout_PS.cpp" /> <source>Job dismantler</source> <translation>Jobs zerlegen</translation> </message> </context> </TS> I recycled a previous XSLT but this doesn't quite produce the right output: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:output indent="yes" encoding="UTF-8"/> <xsl:template match="*"> <xsl:call-template name="createNode"/> </xsl:template> <xsl:template name="createNode"> <xsl:variable name="tagName"> <xsl:value-of select="local-name()"/> </xsl:variable> <xsl:choose> <xsl:when test="$tagName = 'translation'"> <xsl:element name="translation"> <xsl:attribute name="type"> <xsl:value-of select="./@type"/> </xsl:attribute> <xsl:value-of select="../ source"/> <xsl:for-each select="./*"> <xsl:call-template name="createNode"/> </xsl:for-each> </xsl:element> </xsl:when> <xsl:otherwise> <xsl:element name="{$tagName}"> <xsl:if test="count(./*) = 0"> <xsl:value-of select="."/> </xsl:if> <xsl:for-each select="./*"> <xsl:call-template name="createNode"/> </xsl:for-each> </xsl:element> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> Thanks! Thomas | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
