<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:output indent="yes"/>
	<xsl:template match="diagram">
		<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Helvetica" font-size="10pt">
			<fo:layout-master-set>
				<fo:simple-page-master master-name="all-pages" page-height="29.7cm" page-width="21cm">
					<fo:region-body region-name="xsl-region-body" background-color="white" margin-top="3cm" margin-bottom="3cm" margin-left="3.5cm" margin-right="2cm"/>
					<fo:region-before region-name="xsl-region-before" extent="3cm"/>
					<fo:region-after region-name="xsl-region-after" extent="2cm"/>
				</fo:simple-page-master>
			</fo:layout-master-set>
			<fo:page-sequence master-reference="all-pages">
				<fo:static-content flow-name="xsl-region-before">
					<fo:block margin-left="3.5cm" margin-right="2cm" margin-top="0.8cm">
						<fo:basic-link external-destination="http://www.alt-soft.com"><fo:external-graphic src="url('img/Altsoft Documents - Template A - Header.svg')"/></fo:basic-link>
					</fo:block>
				</fo:static-content>
				<fo:static-content flow-name="xsl-region-after">
					<fo:block margin-left="3.5cm" margin-right="2cm">
						<fo:basic-link external-destination="http://www.alt-soft.com"><fo:external-graphic src="url('img/Altsoft Documents - Template A - Footer.svg')"/></fo:basic-link>
					</fo:block>
				</fo:static-content>
				<fo:flow flow-name="xsl-region-body" font-family="Courier" font-size="10pt">
					<fo:block>
						<xsl:apply-templates select="title"/>
						<fo:block margin="0.5cm">
							<xsl:apply-templates select="description"/>
							<xsl:apply-templates select="values"/>
						</fo:block>
					</fo:block>
				</fo:flow>
			</fo:page-sequence>
		</fo:root>
	</xsl:template>
	<xsl:template match="title">
		<fo:block font-family="Helvetica" font-size="14pt" background-color="lightgrey" padding="4pt" margin="0pt">
			<xsl:value-of select="."/>
		</fo:block>
	</xsl:template>
	<xsl:template match="description">
		<fo:block font-family="Times" font-size="12pt" text-align="justify" text-align-last="left" margin="0pt">
			<xsl:value-of select="."/>
		</fo:block>
	</xsl:template>
	<xsl:template match="values">
		<fo:table  margin="0pt" margin-top="1cm" margin-left="-0.2cm" table-layout="fixed" width="100%" border-separation="0.4cm" border-collapse="separate">
			<xsl:for-each select="item">
				<fo:table-column width="proportional-column-width(1)"/>
			</xsl:for-each>
			<fo:table-body>
				<!--<fo:table-row>
					<xsl:apply-templates select="item" mode="value"/>
				</fo:table-row>-->
				<fo:table-row>
					<xsl:apply-templates select="item" mode="bar"/>
				</fo:table-row>
				<fo:table-row>
					<xsl:apply-templates select="item" mode="name"/>
				</fo:table-row>
			</fo:table-body>
		</fo:table>
	</xsl:template>
	
	<xsl:template match="item" mode="value">
		<fo:table-cell>
			<fo:block text-align="center"><xsl:value-of select="value"/>%</fo:block>
		</fo:table-cell>
	</xsl:template>

      <xsl:template match="item" mode="bar">
		<fo:table-cell display-align="after">
			<fo:block text-align="center"><xsl:value-of select="value"/>%</fo:block>
			<fo:block-container  height="{value}*0.1cm" background-color="{color}"/>
		</fo:table-cell>
	</xsl:template>
	
	<xsl:template match="item" mode="name">
		<fo:table-cell>
			<fo:block text-align="center" font-size="8pt"><xsl:value-of select="name"/></fo:block>
		</fo:table-cell>
	</xsl:template>
</xsl:stylesheet>

