Bonjour,
ça fait des heures que je suis sur ce problème et je pense vraiment avoir besoin d'aide.
J'ai un fichier xml que je reçois et que je ne peux donc pas modifier (hormis l'ajout de la ligne pour le xsl) :
J'essaie de créer un fichier xsl pour formatter l'affichage de ce fichier :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 <?xml version='1.0' encoding='UTF-8'?> <?xml-stylesheet type="text/xsl" href="h:\My Documents\Projets\ConstituantStyleSheet3.xslt"?> <package_D15F xmlns="http://xml.mscibarra.com/ns/msci/deal/D15F" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xml.mscibarra.com/ns/msci/deal/D15F 20100715_20100715_CORE_DM_EAFE_SECURITY_MAIN_DAILY_D.xsd"> <dataset_D15F> <entry calc_date="2010-07-15" security_name="titi"> </entry> <entry calc_date="2010-07-18" security_name="toto"> </entry> </dataset_D15F> </package_D15F>
Evidemment, quand j'affiche mon xml, seules mes entêtes s'affichent...
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 <?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://xml.mscibarra.com/ns/msci/deal/D15F" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xml.mscibarra.com/ns/msci/deal/D15F 20100715_20100715_CORE_DM_EAFE_SECURITY_MAIN_DAILY_D.xsd" > <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="*"> <html> <head> <title></title> </head> <style type="text/css"> table { border-style: solid; border-color: black; border-width: 2px; font-family: Verdana; font-size: 12px; } td { font-family: Verdana; font-size: 12px; border-style: solid; border-color: gray; border-width: 0px; border-bottom-width:1px; border-right-width:1px;} td.header { border-style: solid; border-color: black; border-width: 1px; font-family: Verdana; font-size: 12px; background-color: #DDDDDD; border-bottom-width:2px; padding: 5px; text-align:center; } h2 { font-family: Verdana;} h3 { font-family: Verdana;} td.line1 { background-color: #c6c3bd; } td.line2 { background-color: #cccccc; } </style> <body> <table> <tr> <td class="header"> <b>Calculation date</b> </td> <td class="header"> <b>Security name</b> </td> </tr> <xsl:apply-templates select="//entry" /> </table> </body> </html> </xsl:template> <xsl:template match="entry"> <xsl:choose> <xsl:when test="position() mod 2 = 0"> <tr> <td class="line1"> <xsl:value-of select="@calc_date" /> </td> <td class="line1"> <xsl:value-of select="@security_name" /> </td> </tr> </xsl:when> <xsl:when test="position() mod 2 != 0"> <tr> <td class="line2"> <xsl:value-of select="@calc_date" /> </td> <td class="line2"> <xsl:value-of select="@security_name" /> </td> </tr> </xsl:when> </xsl:choose> </xsl:template> </xsl:stylesheet>
J'ai essayé de mettre "xsi:" dans messans succès ou bien ajouté un ":format" sur la déclaration du xmlns principal puis rajouter ":format" dans les template match mais sans succès non plus.
Code : Sélectionner tout - Visualiser dans une fenêtre à part xsl:template match
Pouvez-vous m'aider svp?
Merci d'avance pour vos réponses
Partager