diff options
Diffstat (limited to 'xsl/langfilter.xsl')
-rw-r--r-- | xsl/langfilter.xsl | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/xsl/langfilter.xsl b/xsl/langfilter.xsl new file mode 100644 index 0000000..827b15f --- /dev/null +++ b/xsl/langfilter.xsl @@ -0,0 +1,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> |