1 <?xml version="1.0"?> 2 <!-- 3 Copyright (C) 2009 Paul Boddie <paul@boddie.org.uk> 4 5 This program is free software; you can redistribute it and/or modify it under 6 the terms of the GNU Lesser General Public License as published by the Free 7 Software Foundation; either version 3 of the License, or (at your option) any 8 later version. 9 10 This program is distributed in the hope that it will be useful, but WITHOUT 11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 13 details. 14 15 You should have received a copy of the GNU Lesser General Public License along 16 with this program. If not, see <http://www.gnu.org/licenses/>. 17 --> 18 <xsl:stylesheet version="1.0" 19 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 20 xmlns:template="http://www.boddie.org.uk/ns/xmltools/template"> 21 22 <xsl:output indent="yes" method="xml"/> 23 24 <!-- Process the root element. --> 25 26 <xsl:template match="/"> 27 <translations> 28 <locale> 29 <xsl:apply-templates select="@*|node()"/> 30 </locale> 31 </translations> 32 </xsl:template> 33 34 35 36 <!-- Handle elements with translation attributes. --> 37 38 <xsl:template match="*[@template:i18n]"> 39 <xsl:choose> 40 <xsl:when test="@template:i18n = '-'"> 41 <translation> 42 <xsl:attribute name="value"> 43 <xsl:copy-of select="text()"/> 44 </xsl:attribute> 45 </translation> 46 </xsl:when> 47 <xsl:otherwise> 48 <translation value="{@template:i18n}"></translation> 49 </xsl:otherwise> 50 </xsl:choose> 51 </xsl:template> 52 53 54 55 <!-- Traverse unknown nodes. --> 56 57 <xsl:template match="@*|node()"> 58 <xsl:apply-templates select="@*|node()"/> 59 </xsl:template> 60 61 </xsl:stylesheet>