<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:po="http://www.xml-buddy.com">
    <xsl:output version="4.01" encoding="UTF-8" indent="no" omit-xml-declaration="no" media-type="text/html" />
    <xsl:template match="/">
        <html>
            <head>
                <title />
            </head>
            <body>
                <xsl:for-each select="po:purchaseOrder">
			<table border="0" table-layout="fixed" width="100%">
                        <tbody>
                            <tr>
                                <td>
						Ship to:<br/><br/>
						<xsl:for-each select="po:shipTo">
							<xsl:call-template name="po:address"/>
						</xsl:for-each>
					  </td>
					
                                <td>
						Bill to:<br/><br/>
						<xsl:for-each select="po:billTo">
							<xsl:call-template name="po:address"/>
						</xsl:for-each>						
					  </td>
                            </tr>
                         </tbody>
                    </table>
                    
                    <div style="height: 20px"></div>
                    
			    <xsl:for-each select="po:items">
				    <table border="0" table-layout="fixed" width="100%">
					<tr><td colspan="5">Items</td></tr>
					<tr>
						<td>Part number</td>
						<td>Name</td>
						<td>Quantity</td>
						<td>US price</td>
						<td>Ship date</td>
					</tr>
					
					<xsl:for-each select="po:item">
					<tr style="background-color:lightsteelblue">
						<td><xsl:value-of select="@partNum"/></td>
						<td><xsl:value-of select="po:productName"/></td>
						<td><xsl:value-of select="po:quantity"/></td>
						<td><xsl:value-of select="po:USPrice"/></td>
						<td><xsl:value-of select="po:shipDate"/></td>
					</tr>
					</xsl:for-each>
				    </table>
			    </xsl:for-each>
                    
                    </xsl:for-each>
                </body>
                
            </html>
         </xsl:template>
         
	<xsl:template name="po:address">
			<xsl:value-of select="po:name"/><br/>
			<xsl:value-of select="po:street"/><br/>
			<xsl:value-of select="po:state"/>&#160;<xsl:value-of select="po:zip"/>&#160;<xsl:value-of select="po:city"/>
	</xsl:template>

</xsl:stylesheet>
