Bonsoir,

Je dois générer un Svg à partir d'un fichier Xml grâce à XSLT.

Le tout marche à peu près correctement à un detail près, je ne peux pas appeler de templates !

J'ai eu beau tout vérifier 10 fois, mon appel reste sans effet alors que le code qui s'y trouve (pour l'instant juste l'affichage d'une ligne ) est valide.

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20001102//EN'
  'http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd'>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	
	<xsl:variable name="largeur" select="400"/>
	<xsl:variable name="hauteur" select="500"/>
	<xsl:variable name="larg_max" select="3"/>
	<xsl:variable name="Ox" select="0"/>
	<xsl:variable name="Oy" select="0"/>
	<xsl:variable name="arrondi" select="$largeur*0.025"/>
	
	<xsl:template match="/diagramme/classes">
		<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" >
			<title>Diagramme de Classes !</title>
			<xsl:for-each select="classe">
				<xsl:variable name="valx" select="50+((position()-1) mod $larg_max)*($largeur+($largeur*0.16)) "/>
				<xsl:variable name="valy" select="floor(((position()-1) div $larg_max))*(1.4 * $hauteur) "/>
				<text x="{($Ox + $valx+ ($largeur * 0.5))  }" y="{$valy+50+($hauteur*0.09)}" style="fill:red;font-weight:bold;text-decoration:overline;text-anchor:middle">
					<xsl:value-of select="nom"/>
				</text>
				<xsl:if test='mere[.!=""]' >
					<xsl:variable name="la_mere"><xsl:value-of select="mere"/></xsl:variable>
					<xsl:call-template name="trace_ligne"/>
					<text x="{($Ox + $valx+ ($largeur * 0.5))  }" y="{$valy+70+($hauteur*0.09)}" style="fill:red;font-weight:bold;text-decoration:overline;text-anchor:middle">xxxxxxxxxx</text>
				</xsl:if>
				<xsl:for-each select="elements">
					<xsl:for-each select="element">
						<text x="{$Ox+$valx+($largeur*0.1)}" y="{$valy+($hauteur*0.3)+(0.08*$hauteur*(position()))}">
							<xsl:variable name="t1">
								<xsl:value-of select="statut"/>
							</xsl:variable>
							<xsl:if test="$t1='protected'">
								<xsl:text> # </xsl:text>
							</xsl:if>
							<xsl:if test="$t1='public'">
								<xsl:text> + </xsl:text>
							</xsl:if>
							<xsl:if test="$t1='private'">
								<xsl:text> - </xsl:text>
							</xsl:if>
							<xsl:value-of select="$t1"/>
							<xsl:text> </xsl:text>
							<xsl:variable name="t2">
								<xsl:value-of select="type"/>
							</xsl:variable>
							<xsl:value-of select="$t2"/>
							<xsl:text> </xsl:text>
							<xsl:variable name="t3">
								<xsl:value-of select="nom"/>
							</xsl:variable>
							<xsl:value-of select="$t3"/>
							<xsl:text> </xsl:text>
							<xsl:if test="count(attribut)>0">
									( 
									<xsl:for-each select="attribut">
									<xsl:value-of select="@type"/>
									<xsl:text> </xsl:text>
									<xsl:value-of select="."/>
									<xsl:if test="position()!=last()">
										,
										</xsl:if>
								</xsl:for-each>
									)
								</xsl:if>
							<xsl:variable name="larg">
								<xsl:value-of select="string-length(concat($t1,$t2,$t3))"/>
							</xsl:variable>
						</text>
					</xsl:for-each>
				</xsl:for-each>
				<rect x="{$Ox + $valx}" y="{$valy+50}" width="{$largeur}" height="{$hauteur}" stroke="black" fill="none" rx="{$arrondi}"/>
				<rect x="{$Ox + $valx}" y="{$valy+50 }" width="{$largeur}" height="{$hauteur * 0.16 }" stroke="black" fill="none" rx="{$arrondi}"/>
			</xsl:for-each>
							</svg>
	</xsl:template>
	
		<xsl:template name="trace_ligne"> 
			 <line x1="12" y1="12" x2="300" y2="500" stroke="black" fill="black" />
		</xsl:template>

</xsl:stylesheet>
Je précise que l'instruction située juste sous l'appel fonctionne, il ne s'agit pas d'un problème de if....

Merci