Bonjour,
A partir d'un fichier XML j'effectue une transformation XSL pour générer un fichier texte à plat.
Lorsque je lance la transformation avec XML Spy le résulat attendu est correct.
Par contre lorsque je lance la transformation avec Saxon le résultat n'est pas celui attendu. Le fichier texte généré est indenté, il contient des tabulation et des retours lignes non attendus.
Partie du code XSL :
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
45
 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes">
	<xsl:import href="communs.xsl"/>
	<xsl:output method="text" media-type="text/plain" indent="no"/>
	<xsl:template match="/ListOfPKT/PKT">
		<!--création de la variable cpt pour connaitre la position du PKT que l'on est en train de traiter-->
		<xsl:variable name="cpt">
			<xsl:number count="//PKT"/>
		</xsl:variable>
		<!--test si le ManagingTerritory = TID ou LIF ou LIV car sinon on ne traite pas ce PKT-->
		<xsl:if test="/ListOfPKT/PKT[position()=$cpt]/ManagingTerritory/.='TID' or /ListOfPKT/PKT[position()=$cpt]/ManagingTerritory/.='LIF' or /ListOfPKT/PKT[position()=$cpt]/ManagingTerritory/.='LIV'">
			<!--traitement du 1er type d'enregistrement-->01<!--appel du template WriteData qui met à jour les champs du fichier cible-->
			<xsl:call-template name="WriteData">
				<!--On lui passe la variable cpt (pour la même raison que plus haut)-->
				<xsl:with-param name="cptPara">
					<xsl:value-of select="$cpt"/>
				</xsl:with-param>
			</xsl:call-template>
			<!--traitement du 2ème type d'enregistrement-->
11<xsl:call-template name="WriteData">
				<xsl:with-param name="cptPara">
					<xsl:value-of select="$cpt"/>
				</xsl:with-param>
			</xsl:call-template>
</xsl:if>
	</xsl:template>
	<xsl:template name="WriteData">
		<xsl:param name="cptPara"/>2GBLV    <xsl:call-template name="Codpev">
			<xsl:with-param name="cptPara">
				<xsl:value-of select="$cptPara"/>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:variable name="test" select="/ListOfPKT/PKT[position()=$cptPara]/DesCliBlNbr/."/>
		<xsl:call-template name="JustifierNumerique">
			<xsl:with-param name="LongueurNumVoulue">7</xsl:with-param>
			<xsl:with-param name="ChampAMapper" select="/ListOfPKT/PKT[position()=$cptPara]/DesCliBlNbr/."/>
		</xsl:call-template>
		<xsl:if test="/ListOfPKT/PKT[position()=$cptPara]/ManagingTerritory/.='LIF'">
			<xsl:call-template name="JustifierAlphanumerique">
				<xsl:with-param name="LongueurAlphanumVoulue">12</xsl:with-param>
				<xsl:with-param name="ChampAMapper" select="/ListOfPKT/PKT[position()=$cptPara]/ShipToCnty/."/>
			</xsl:call-template>
		</xsl:if>
...
et voici le résultat obtenu :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
 
 
			01
			2GBLV    GP1F    0000005101720    
 
112GBLV    GP1F    0000005101720             
 
			01
			2GBLV    GT1     0000004~                 
 
112GBLV    GT1     0000004~                  ~