forked from coopengo/account
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocalize.xsl
34 lines (34 loc) · 1.19 KB
/
localize.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?xml version="1.0"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="lang"/>
<xsl:template match="record[@id]">
<xsl:copy>
<xsl:attribute name="id">
<xsl:value-of select="attribute::id"/>_<xsl:value-of select="$lang"/>
</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*">
<xsl:choose>
<xsl:when test="name()='id' or name()='lang'"></xsl:when>
<xsl:when test="name()='ref'">
<xsl:attribute name="ref">
<xsl:value-of select="."/>_<xsl:value-of select="$lang"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:copy/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="node()">
<xsl:choose>
<xsl:when test="@lang=$lang or not(@lang)">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:transform>