Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 16th, 2010 | Syntax: XML | Size: 2.43 KB | Hits: 36 | Expires: Never
Copy text to clipboard
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3. <xsl:include href="svglib.xsl" />
  4. <xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd" indent="yes"/>
  5.  
  6. <xsl:attribute-set name="polylin">
  7.         <xsl:attribute name="fill">none</xsl:attribute>
  8.         <xsl:attribute name="stroke">yellow</xsl:attribute>
  9.         <xsl:attribute name="stroke-width">10</xsl:attribute>
  10. </xsl:attribute-set>
  11.  
  12. <xsl:template match="/">
  13.         <html>
  14.                 <head>
  15.                         <title>Liste des communes de la Haute Garonne</title>
  16.                 </head>
  17.                 <body>
  18.                         <xsl:variable name="max">
  19.                                 <xsl:for-each select="//city">
  20.                                         <xsl:sort data-type="number" select="@nbHabitants" order="descending" />
  21.                                         <xsl:if test="position()=1">
  22.                                                 <xsl:value-of select="@nbHabitants" />
  23.                                         </xsl:if>
  24.                                 </xsl:for-each>
  25.                         </xsl:variable>
  26.                         <xsl:variable name="min">
  27.                                 <xsl:for-each select="//city">
  28.                                         <xsl:sort data-type="number" select="@nbHabitants" order="ascending" />
  29.                                         <xsl:if test="position()=1">
  30.                                                 <xsl:value-of select="@nbHabitants" />
  31.                                         </xsl:if>
  32.                                 </xsl:for-each>
  33.                         </xsl:variable>
  34.                         <svg xmlns="http://www.w3.org/2000/svg" width="18cm" height="6cm" viewBox="0 0 1000 500">
  35.                                 <rect x="0" y="0" width="1000" height="500" fill="none" stroke="blue" stroke-width="2" />
  36.                                 <rect x="200" y="1" width="800" height="400" fill="none" stroke="blue" stroke-width="2" />
  37.                                 <xsl:element name="polyline" use-attribute-sets="polylin">
  38.                                         <xsl:attribute name="points">
  39.                                                 <xsl:for-each select="//city">
  40.                                                         <xsl:call-template name="points">
  41.                                                                 <xsl:with-param name="x">
  42.                                                                         <xsl:value-of select="position()" />
  43.                                                                 </xsl:with-param>
  44.                                                                 <xsl:with-param name="y">
  45.                                                                         <xsl:value-of select="@nbHabitants" />
  46.                                                                 </xsl:with-param>
  47.                                                                 <xsl:with-param name="dx">
  48.                                                                         <xsl:value-of select="last()" />
  49.                                                                 </xsl:with-param>
  50.                                                                 <xsl:with-param name="dy">
  51.                                                                         <xsl:value-of select="$max - $min" />
  52.                                                                 </xsl:with-param>
  53.                                                                 <xsl:with-param name="w">800</xsl:with-param>
  54.                                                                 <xsl:with-param name="h">400</xsl:with-param>
  55.                                                                 <xsl:with-param name="gx">200</xsl:with-param>
  56.                                                                 <xsl:with-param name="gy">0</xsl:with-param>
  57.                                                         </xsl:call-template>
  58.                                                 </xsl:for-each>
  59.                                         </xsl:attribute>
  60.                                 </xsl:element>
  61.                         </svg>
  62.                 </body>
  63.         </html>
  64. </xsl:template>
  65.  
  66. </xsl:stylesheet>