github.com/matislovas/ratago@v0.0.0-20240408115641-cc0857415a7a/xslt/testdata/REC2/svg.xsl (about)

     1  <xsl:stylesheet version="1.0"
     2                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     3                  xmlns="http://www.w3.org/Graphics/SVG/SVG-19990812.dtd">
     4  
     5  <xsl:output method="xml" indent="yes" media-type="image/svg"/>
     6  
     7  <xsl:template match="/">
     8  
     9  <svg width = "3in" height="3in">
    10      <g style = "stroke: #000000"> 
    11          <!-- draw the axes -->
    12          <line x1="0" x2="150" y1="150" y2="150"/>
    13          <line x1="0" x2="0" y1="0" y2="150"/>
    14          <text x="0" y="10">Revenue</text>
    15          <text x="150" y="165">Division</text>
    16          <xsl:for-each select="sales/division">
    17              <!-- define some useful variables -->
    18  
    19              <!-- the bar's x position -->
    20              <xsl:variable name="pos"
    21                            select="(position()*40)-30"/>
    22  
    23              <!-- the bar's height -->
    24              <xsl:variable name="height"
    25                            select="revenue*10"/>
    26  
    27              <!-- the rectangle -->
    28              <rect x="{$pos}" y="{150-$height}"
    29                    width="20" height="{$height}"/>
    30  
    31              <!-- the text label -->
    32              <text x="{$pos}" y="165">
    33                  <xsl:value-of select="@id"/>
    34              </text> 
    35  
    36              <!-- the bar value -->
    37              <text x="{$pos}" y="{145-$height}">
    38                  <xsl:value-of select="revenue"/>
    39              </text>
    40          </xsl:for-each>
    41      </g>
    42  </svg>
    43  
    44  </xsl:template>
    45  </xsl:stylesheet>