J'ai un fichier XML sur les données météorologiques de 3 villes différentes, maintenant je veux utiliser XSl le convertir en 3 tables selon les attributs de localisation (Calgary, Charlottetown et Ottawa) dans mon xml. Le xls que j'ai maintenant convertit juste le xml en une table, Quelqu'un peut-il me donner un indice sur la façon de convertir le fichier xml en différentes tables par l'attribut xml?
Ceci est mon xmlXSL Convertir le fichier XML en 3 tables
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="weatherdata.xsl"?>
<weatherdata>
<stationdata weatherdate="2015-1-1" location="Calgary">
<maxtemp>1.1°C</maxtemp>
<mintemp>-6.1°C</mintemp>
<totalrain>0 mm</totalrain>
<totalsnow>0cm</totalsnow>
</stationdata>
<stationdata weatherdate="2015-1-2" location="Calgary">
<maxtemp>-3.4°C</maxtemp>
<mintemp>-18.2°C</mintemp>
<totalrain>0 mm</totalrain>
<totalsnow>5cm</totalsnow>
</stationdata>
<stationdata weatherdate="2015-1-3" location="Calgary">
<maxtemp>-18.1°C</maxtemp>
<mintemp>-21.1°C</mintemp>
<totalrain>0 mm</totalrain>
<totalsnow>1.6cm</totalsnow>
</stationdata>
<stationdata weatherdate="2015-01-01" location="Charlottetown">
<maxtemp>-3.5°C</maxtemp>
<mintemp>-15°C</mintemp>
<totalrain>0 mm</totalrain>
<totalsnow>0.4cm</totalsnow>
</stationdata>
<stationdata weatherdate="2015-01-02" location="Charlottetown">
<maxtemp>-1°C</maxtemp>
<mintemp>-13.2°C</mintemp>
<totalrain>0 mm</totalrain>
<totalsnow>0.6cm</totalsnow>
</stationdata>
<stationdata weatherdate="2015-01-03" location="Charlottetown">
<maxtemp>-11.8°C</maxtemp>
<mintemp>-16.1°C</mintemp>
<totalrain>0 mm</totalrain>
<totalsnow>0cm</totalsnow>
</stationdata>
stationdata weatherdate="2015-01-01" location="Ottawa">
<maxtemp>-3°C</maxtemp>
<mintemp>-8.1°C</mintemp>
<totalrain>0 mm</totalrain>
<totalsnow>0.2cm</totalsnow>
</stationdata>
<stationdata weatherdate="2015-01-02" location="Ottawa">
<maxtemp>-3.8°C</maxtemp>
<mintemp>-15.8°C</mintemp>
<totalrain>0 mm</totalrain>
<totalsnow>0cm</totalsnow>
</stationdata>
<stationdata weatherdate="2015-01-03" location="Ottawa">
<maxtemp>-9.6°C</maxtemp>
<mintemp>-15.5°C</mintemp>
<totalrain>0 mm</totalrain>
<totalsnow>18cm</totalsnow>
</stationdata>
</weatherdata>
Ceci est mon xls
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/weatherdata">
<html>
<head>
<title>weather data</title>
</head>
<body>
<h1>Calgary-Temperature Summary(2015)</h1>
<table border="1">
<tr>
<th>Data</th>
<th>Maximum Temperature(°C)</th>
<th>Minimum Temperature(°C)</th>
<th>Total Rain(mm)</th>
<th>Total Snow(cm)</th>
</tr>
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="stationdata">
<tr>
<td><xsl:value-of select="@weatherdate"/></td>
<td><xsl:value-of select="maxtemp"/></td>
<td><xsl:value-of select="mintemp"/></td>
<td><xsl:value-of select="totalrain"/></td>
<td><xsl:value-of select="totalsnow"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
les noms de lieu - Calgary, Charlottetown et Ottawa - connu à l'avance? IOW, peuvent-ils être codés en dur dans la feuille de style? –