<?xml version="1.0"?>
<!-- tested with build-in processor in XMLSpy 2007 and with Saxon8b in Oxygen -->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xsl:strip-space elements="*"/>
	<xsl:output method="text"/>
	<xsl:template match="products/product">
		<!--variables normalized input-->
		<xsl:variable name="idN" select="normalize-space(@id)"/>
		<xsl:variable name="nameN" select="normalize-space(name)"/>
		<xsl:variable name="priceN" select="normalize-space(price)"/>
		<xsl:variable name="stockN" select="normalize-space(stock)"/>
		<xsl:variable name="countryN" select="normalize-space(country)"/>
		<!--variables formated input-->
		<xsl:variable name="priceNF" select="format-number(xs:decimal($priceN), '#,##0.00')"/>
		<!--variables extra spaces-->
		<xsl:variable name="idSpace" select="for $a in 1 to (3 - string-length($idN)) return ' '"/>
		<xsl:variable name="nameSpace"
			select="for $a in 1 to (8 - string-length($nameN)) return ' '"/>
		<xsl:variable name="priceSpace"
			select="for $a in 1 to (10 - string-length($priceNF)) return ' '"/>
		<xsl:variable name="stockSpace"
			select="for $a in 1 to (3 - string-length($stockN)) return ' '"/>
		<xsl:variable name="countrySpace"
			select="for $a in 1 to (10 - string-length($countryN)) return ' '"/>
		<!--fixed output begins here-->
		<xsl:value-of
			select="concat($idN, string-join($idSpace, ''), string-join($nameSpace, ''), $nameN, string-join($priceSpace, ''), $priceNF, string-join($stockSpace, ''), $stockN, string-join($countrySpace, ''), $countryN)"
		/>
		<xsl:text>&#xA;</xsl:text>
	</xsl:template>
	<!-- Version 2c -->
	<!-- 1) We have formatted the price output using decimal-format. -->
	<!-- 2) Note: We don't declare the English decimal format at the top relying on English as default. -->
	<!-- 3) We use only one value-of and one concat to create output. -->
	<!-- 4) Note that in 2.0 we need to use "xs:decimal", and we must remember to declare the namespace. --> 
	<!-- 5) XMLSpy's built in processor is stripping whitespace-only text-nodes. Xsl:strip-space is not needed. -->
	<!-- 6) In Saxon we must include xsl:strip-space or delete the linefeed at the end of last template. -->
</xsl:stylesheet>
