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
| <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<html>
<head>
<title/>
</head>
<body>
<h1>Histogramme par pays</h1>
<p>Le pourcentage d'utilisateurs d'internet</p>
<xsl:variable name="countries"
select="distinct-values(ROOT/data/record/field[@name='Country or Area'])"/>
<xsl:variable name="ROOT" select="/ROOT"/>
<xsl:for-each select="$countries">
<xsl:variable name="country" select="."/>
<h1>
<xsl:value-of select="."/>
</h1>
<svg width="1000" height="500">
<xsl:apply-templates select="$ROOT/data/record[field=$country]"/>
<line x1="90" y1="200" x2="90" y2="20"
style="stroke:black;stroke-width:1.5;marker-end;"/>
<line x1="90" y1="200" x2="1000" y2="200"
style="stroke:black;stroke-width:1.5;marker-end;"/>
</svg>
</xsl:for-each>
</body>
</html>
</xsl:template>
<xsl:template match="record">
<rect fill="red" x="{(field[@name='Year'] -1990)*50+100}" y="{200-field[@name='Value'] *2}"
width="40" height="{field[@name='Value'] *2}"/>
<text x="{(field[@name='Year'] -1990)*50+100}" y="220">
<xsl:value-of select="field[@name='Year']"/>
</text>
<text x="{(field[@name='Year'] -1990)*50+108}" y="{180-field[@name='Value'] *2}">
<xsl:value-of select="field[@name='Value']"/>
</text>
</xsl:template>
</xsl:stylesheet> |
Partager