Bonjour,

J'utilise un fichier XSL pour patcher un fichier de configuration de Tomcat et rajouter quelques valeurs. Mon soucis actuel est que mon fichier de sortie a une mise en page différente de celui d'entrée. Beaucoup de retours de à la ligne sont perdus.

Par exemple mon fichier d'entrée ressemble à cela :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
<?xml version='1.0' encoding='utf-8'?>
 
<!--
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 - Tomcat 5.5 server.xml file with some configuration steps for JOnAS already done.
 -   Realm already set
 -   Examples with a JOnASStandardContext context.
 -
 - $Id: server.xml 7934 2006-01-25 15:43:30 +0000 (Wed, 25 Jan 2006) sauthieg $
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -->
 
<!-- Note that component elements are nested corresponding to their
     parent-child relationships with each other -->
 
<!-- A "Server" is a singleton element that represents the entire JVM,
     which may contain one or more "Service" instances.  The Server
     listens for a shutdown command on the indicated port.
 
     Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" or "Loggers" at this level.
 -->
 
<Server>
...
J'obtiens en sortie ce type de résultat :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
<?xml version="1.0" encoding="UTF-8"?><!--
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 - Tomcat 5.5 server.xml file with some configuration steps for JOnAS already done.
 -   Realm already set
 -   Examples with a JOnASStandardContext context.
 -
 - $Id: server.xml 7934 2006-01-25 15:43:30 +0000 (Wed, 25 Jan 2006) sauthieg $
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 --><!-- Note that component elements are nested corresponding to their
     parent-child relationships with each other --><!-- A "Server" is a singleton element that represents the entire JVM,
     which may contain one or more "Service" instances.  The Server
     listens for a shutdown command on the indicated port.
 
     Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" or "Loggers" at this level.
 --><Server>
...
Je souhaiterais que ma transformation préserver la mise en page précédente. Sauriez-vous comment faire cela ?

Voici mon fichier XSL dans son ensemble:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
35
36
37
38
39
40
41
42
43
44
<?xml version="1.0" encoding="UTF-8" ?>
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xml:space="preserve">
    <xsl:output method="xml" indent="true" />
 
    <xsl:preserve-space elements="*" />
 
    <xsl:template match="Host" xml:space="preserve">
        <xsl:element name="{name()}" >
            <xsl:apply-templates select="@*"/>
            <xsl:text>
                <Context path="/log" docBase="../logs" reloadable="true">
                </Context>                
            </xsl:text>
            <xsl:apply-templates select="*"/>
        </xsl:element>
    </xsl:template>
 
    <xsl:template match="Realm" xml:space="preserve">  
        <xsl:element name="{name()}" >
            <xsl:if test="@className='org.objectweb.jonas.security.realm.web.catalina55.JACC'">
                <xsl:attribute name="className">org.objectweb.jonas.security.realm.web.catalina55.JAAS</xsl:attribute>
            </xsl:if>
            <xsl:if test="@className!='org.objectweb.jonas.security.realm.web.catalina55.JACC'">
                <xsl:apply-templates select="@*"/>
            </xsl:if>
        </xsl:element>
    </xsl:template>
 
    <xsl:template match="@*" xml:space="preserve">
        <xsl:copy />
    </xsl:template>
 
    <xsl:template match="*" xml:space="preserve">
        <xsl:element name="{name()}" >
            <xsl:apply-templates select="* | text() | @* | comment()"/>
        </xsl:element>
    </xsl:template>
 
    <xsl:template match="comment()" xml:space="preserve" >
        <xsl:copy/>
    </xsl:template>    
 
</xsl:stylesheet>

Merci pour votre aide.

Xavier