Bonjour tout le monde,
J'ai un petit soucis XSL.
Voici mon XML:
Je voudrais ce resultat.Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 <property> <prices2012> <jan>2750</jan> <feb>2750</feb> <mar>3500</mar> <apr>3995</apr> <may>3995</may> <jun>5750</jun> <jul>8500</jul> <aug>8500</aug> <sep>5750</sep> <oct>3995</oct> <nov>2750</nov> <dec>2750</dec> </prices2012> </property>
J'ai cree ce XSL mais il ne prend que la valeur du premier mois pour tous, au lieux de changer. Pourtant il prend bien en compte le nom de la balise.Code:
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 <Rate> <StartDate>2012-01-01</StartDate> <EndDate>2012-01-31</EndDate> <WeeklyRate>2750</WeeklyRate> <Name>January</Name> </Rate> <Rate> <StartDate>2012-02-01</StartDate> <EndDate>2012-02-27</EndDate> <WeeklyRate>2750</WeeklyRate> <Name>February</Name> </Rate> <Rate> <StartDate>2012-03-01</StartDate> <EndDate>2012-03-30</EndDate> <WeeklyRate>3500</WeeklyRate> <Name>March</Name> </Rate> <Rate> <StartDate>2012-04-01</StartDate> <EndDate>2012-04-31</EndDate> <WeeklyRate>3995</WeeklyRate> <Name>April</Name> </Rate> etc... pour tous les mois
Pourquoi n'arrives-je pas a avoir la valeur du noeud courant correctement?Code:
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 <xsl:template match='property'> <xsl:for-each select='child::prices2012'> <xsl:apply-templates select="node()"> <xsl:with-param name="month"><xsl:value-of select="*" /></xsl:with-param> </xsl:apply-templates> </xsl:for-each> </xsl:template> <xsl:template match='jan'> <xsl:param name='month' /> <xsl:if test="$month != ''"> <Rate> <StartDate>2012-01-01</StartDate> <EndDate>2012-01-31</EndDate> <WeeklyRate><xsl:value-of select='format-number($month,"0")' /></WeeklyRate> <Name>January</Name> </Rate> </xsl:if> </xsl:template> <xsl:template match='fev'> <xsl:param name='month' /> <xsl:if test="$month != ''"> <Rate> <StartDate>2012-02-01</StartDate> <EndDate>2012-02-27</EndDate> <WeeklyRate><xsl:value-of select='format-number($month,"0")' /></WeeklyRate> <Name>February</Name> </Rate> </xsl:if> </xsl:template> etc... pour tous les mois
J'ai essaye plein de choses mais rien ne marche: ".", "/", "current()","node()","selft","self::*" ...
Que dois-je faire pour corriger ce probleme?
Merci beaucoup.