<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="text"/>
	<xsl:template match="/">
		<xsl:for-each select="products/product">
			<!--variables extra spaces-->
			<xsl:variable name="idSpace">
				<xsl:call-template name="times">
					<xsl:with-param name="counter" select="3 - string-length(@id)"/>
				</xsl:call-template>
			</xsl:variable>
			<xsl:variable name="nameSpace">
				<xsl:call-template name="times">
					<xsl:with-param name="counter" select="8 - string-length(name)"/>
				</xsl:call-template>
			</xsl:variable>
			<xsl:variable name="priceSpace">
				<xsl:call-template name="times">
					<xsl:with-param name="counter" select="10 - string-length(price)"/>
				</xsl:call-template>
			</xsl:variable>
			<xsl:variable name="stockSpace">
				<xsl:call-template name="times">
					<xsl:with-param name="counter" select="3 - string-length(stock)"/>
				</xsl:call-template>
			</xsl:variable>
			<xsl:variable name="countrySpace">
				<xsl:call-template name="times">
					<xsl:with-param name="counter" select="10 - string-length(country)"/>
				</xsl:call-template>
			</xsl:variable>
			<!--fixed output begins here-->
			<xsl:value-of select="concat(@id, $idSpace)"/><!-- align left -->
			<xsl:value-of select="concat($nameSpace, name)"/><!-- align right -->
			<xsl:value-of select="concat($priceSpace, price)"/><!-- align right -->
			<xsl:value-of select="concat($stockSpace, stock)"/><!-- align right -->
			<xsl:value-of select="concat($countrySpace, country)"/><!-- aligned right -->
			<xsl:text>&#xA;</xsl:text>
			</xsl:for-each>
	</xsl:template>
	<!--template to return spaces x number of times-->
	<xsl:template name="times">
		<xsl:param name="counter"/>
		<xsl:if test="$counter > 0">
			<xsl:value-of select="' '"/>
			<xsl:call-template name="times">
				<xsl:with-param name="counter" select="$counter - 1"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>