Bonjour à tous,
Je récupère via un web service un fichier XML dont voici un résumé très allégé:
Voici le fichier XSL que j'ai créé pour la mise en forme:
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 <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet href="test.xsl" type="text/xsl"?> <root> <Products xmlns="" LastRefresh="1/1/2015 10:11:36 PM"> <Product ID="243512" ModelName="16593" ManufacturerID="16593" EAN="8713439165937"> <Description>DT Cordless</Description> <Description2>Retail, US-Layout, Black</Description2> <VatRate>21</VatRate> <QuantityOnHand>128</QuantityOnHand> <StockLevel>Good</StockLevel> <Status>S</Status> <Brand>Trust</Brand> <MasterGroup>Input Device</MasterGroup> <ProductGroup>Mouse & Keyboard Combination</ProductGroup> <UnitPrice>14,71</UnitPrice> <Staffels/> <Accruels> <Accruel Code="BEBATBE" Description="Bebat Belgium" UnitPrice="0,30"/> <Accruel Code="RECUPEL" Description="Recupel Belgium" UnitPrice="0,08"/> </Accruels> </Product> <Product ID="243521" ModelName="16599" ManufacturerID="16599" EAN="8713439165999"> <Description>DT Cordless</Description> <Description2>Retail, BE-Layout, Black</Description2> <VatRate>21</VatRate> <QuantityOnHand>9</QuantityOnHand> <StockLevel>Low</StockLevel> <Status>S</Status> <Brand>Trust</Brand> <MasterGroup>Input Device</MasterGroup> <ProductGroup>Mouse & Keyboard Combination</ProductGroup> <UnitPrice>13,00</UnitPrice> <Staffels/> <Accruels> <Accruel Code="BEBATBE" Description="Bebat Belgium" UnitPrice="0,30"/> <Accruel Code="RECUPEL" Description="Recupel Belgium" UnitPrice="0,08"/> </Accruels> </Product> </Products> </root>
Tout fonctionne, mais en fait je ne sais pas comment je pourrais afficher dans les 4 dernières colonnes de mon tableau:
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 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE xsl:stylesheet []> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/> <xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Mis en forme avec XSL</title> </head> <body> <table border="1"> <tr> <td>ID produit</td> <td>Nom</td> <td>ManufacturerID</td> <td>Code EAN</td> <td>Description 1</td> <td>Description 2</td> <td>TVA</td> <td>Stock</td> <td>Prochaine livraison</td> <td>Niveau de stock</td> <td>Statut</td> <td>Marque</td> <td>Gatégorie</td> <td>Sous-catégorie</td> <td>Prix d'achat</td> <td>Recupel</td> <td>Bebat</td> <td>Auvibel</td> <td>Reprobel</td> </tr> <xsl:for-each select="root/Products/Product"> <tr> <td><xsl:value-of select="@ID"/></td> <td><xsl:value-of select="@ModelName"/></td> <td><xsl:value-of select="@ManufacturerID"/></td> <td><xsl:value-of select="@EAN"/></td> <td><xsl:value-of select="Description"/></td> <td><xsl:value-of select="Description2"/></td> <td><xsl:value-of select="VatRate"/></td> <td><xsl:value-of select="QuantityOnHand"/></td> <td><xsl:value-of select="NextDeliveryDate"/></td> <td><xsl:value-of select="StockLevel"/></td> <td><xsl:value-of select="Status"/></td> <td><xsl:value-of select="Brand"/></td> <td><xsl:value-of select="MasterGroup"/></td> <td><xsl:value-of select="ProductGroup"/></td> <td><xsl:value-of select="UnitPrice"/></td> <td></td> <td></td> <td></td> <td></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
la valeur de l'attribut "UnitPrice" de chaque balise "Accruel" dont l'attribut "Code" = "RECUPEL"
la valeur de l'attribut "UnitPrice" de chaque balise "Accruel" dont l'attribut "Code" = "BEBATBE"
la valeur de l'attribut "UnitPrice" de chaque balise "Accruel" dont l'attribut "Code" = "AUVIBEL"
la valeur de l'attribut "UnitPrice" de chaque balise "Accruel" dont l'attribut "Code" = "REPROBEL"
J'ai beau chercher sur google une méthode, je tombe sur d'autres cas de figure.
Mes sources sont en pièces jointes.
Pourriez-vous m'aider svp?
D'avance merci
Partager