<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:output method="xml" encoding="ISO-8859-1" indent="yes" doctype-public="-//Apache Software Foundation//DTD Struts Configuration 1.2//EN http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"/>
    
    <xsl:template match="processing-instruction()">
        <xsl:copy-of select="."/>
    </xsl:template>
    
    <xsl:template match="struts-config">
        <xsl:text disable-output-escaping="yes">&lt;!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"&gt;</xsl:text>
        <xsl:call-template name="writeElement">
            <xsl:with-param name="el" select="."/>
        </xsl:call-template>
    </xsl:template>
    
    <xsl:template match="*">
        <xsl:copy>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template name="writeElement">
        <xsl:param name="el"/>
            <xsl:choose>
                <xsl:when test="local-name($el)='forward' and local-name($el/parent::node())='action' and $el/parent::node()/@path='/deconnexion'">
                    <forward name="success" path="/login.jsp?logout=1" redirect="true"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:element name="{local-name($el)}" namespace="{namespace-uri($el)}">
                        <xsl:for-each select="$el/@*">
                        <xsl:attribute name="{local-name(.)}" namespace="{namespace-uri($el)}">
                            <xsl:value-of select="."/>
                        </xsl:attribute>
                    </xsl:for-each>
                    <xsl:for-each select="$el/*">
                        <xsl:call-template name="writeElement">
                            <xsl:with-param name="el" select="."/>
                        </xsl:call-template>
                    </xsl:for-each>
                    <xsl:value-of select="$el/text()"/>
                    </xsl:element>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:value-of select="$el/text()"/>
    </xsl:template>
    
</xsl:stylesheet>
