<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="svglib.xsl" />
<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd" indent="yes"/>
<xsl:attribute-set name="polylin">
<xsl:attribute name="fill">none</xsl:attribute>
<xsl:attribute name="stroke">yellow</xsl:attribute>
<xsl:attribute name="stroke-width">10</xsl:attribute>
</xsl:attribute-set>
<xsl:template match="/">
<html>
<head>
<title>Liste des communes de la Haute Garonne</title>
</head>
<body>
<xsl:variable name="max">
<xsl:for-each select="//city">
<xsl:sort data-type="number" select="@nbHabitants" order="descending" />
<xsl:if test="position()=1">
<xsl:value-of select="@nbHabitants" />
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="min">
<xsl:for-each select="//city">
<xsl:sort data-type="number" select="@nbHabitants" order="ascending" />
<xsl:if test="position()=1">
<xsl:value-of select="@nbHabitants" />
</xsl:if>
</xsl:for-each>
</xsl:variable>
<svg xmlns="http://www.w3.org/2000/svg" width="18cm" height="6cm" viewBox="0 0 1000 500">
<rect x="0" y="0" width="1000" height="500" fill="none" stroke="blue" stroke-width="2" />
<rect x="200" y="1" width="800" height="400" fill="none" stroke="blue" stroke-width="2" />
<xsl:element name="polyline" use-attribute-sets="polylin">
<xsl:attribute name="points">
<xsl:for-each select="//city">
<xsl:call-template name="points">
<xsl:with-param name="x">
<xsl:value-of select="position()" />
</xsl:with-param>
<xsl:with-param name="y">
<xsl:value-of select="@nbHabitants" />
</xsl:with-param>
<xsl:with-param name="dx">
<xsl:value-of select="last()" />
</xsl:with-param>
<xsl:with-param name="dy">
<xsl:value-of select="$max - $min" />
</xsl:with-param>
<xsl:with-param name="w">800</xsl:with-param>
<xsl:with-param name="h">400</xsl:with-param>
<xsl:with-param name="gx">200</xsl:with-param>
<xsl:with-param name="gy">0</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:attribute>
</xsl:element>
</svg>
</body>
</html>
</xsl:template>
</xsl:stylesheet>