aboutsummaryrefslogtreecommitdiff
path: root/xsl/langfilter.xsl
blob: 827b15f0dc8d0993b26bb54ad098a62c869cba1b (plain)
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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:param name="lang"/>
 
<xsl:template match="/html">
 <xsl:copy>
  <xsl:attribute name="xml_lang"><xsl:value-of select="$lang"/></xsl:attribute>
  <xsl:apply-templates/>
 </xsl:copy>
</xsl:template>
 
<xsl:template match="*">
 <xsl:choose>
  <xsl:when test="lang($lang) or not(ancestor-or-self::*[@xml:lang])">
   <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
  </xsl:when>
  <xsl:otherwise/>
 </xsl:choose>
</xsl:template>
 
<xsl:template match="@*|text()">
  <xsl:copy/>
</xsl:template>
 
</xsl:stylesheet>