<?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:block margin="0.5cm">
			<xsl:apply-templates select="item"/>
		</fo:block>
		<fo:block margin="0.5cm">Legend</fo:block>
		<fo:table  margin="0.5cm" border="1pt solid black">
			<fo:table-body>
				<xsl:for-each select="item">
					<fo:table-row margin="0.1cm">
						<fo:table-cell>
							<fo:block color="{color}" padding="5pt"  margin="0pt"><xsl:value-of select="color"/></fo:block>
						</fo:table-cell>
						<fo:table-cell wrap-option="no-wrap">
							<fo:block padding="5pt"  margin="0pt"><xsl:value-of select="name"/></fo:block>
						</fo:table-cell>
						<fo:table-cell wrap-option="no-wrap">
							<fo:block padding="5pt" margin="0pt"><xsl:value-of select="value"/>%</fo:block>
						</fo:table-cell>
					</fo:table-row>
				</xsl:for-each>

			</fo:table-body>
		</fo:table>
	</xsl:template>

	<xsl:template match="item">
		<fo:inline line-height="2em" background-color="{color}" width="{value}%"/>
	</xsl:template>

</xsl:stylesheet>

