<?xml version="1.0"?>
<!-- edited with XML Spy v2.5 NT  - http://www.xmlspy.com -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns:html="http://www.w3.org/tr/rec-html40" result-ns="">
<xsl:template match="/">
<TABLE border='1'>
<THEAD>
<xsl:apply-templates select="/xml/s:Schema/s:ElementType[@name='row']/s:AttributeType"/>
</THEAD>
<TBODY CLASS="TableBody" id='tableBody'>
	<xsl:apply-templates select="/xml/rs:data/z:row" order-by="@*[2]"/>						
</TBODY>
</TABLE>
</xsl:template>
	
	
<xsl:template match="s:AttributeType">
	<xsl:choose>
		<xsl:when test="@rs:hidden" />
		<xsl:when test="/xml/layout/field[@name $ieq$ context(-1)/@name]/@visible[text() $ieq$ 'false']"/>
		<xsl:otherwise>
			<th>
				<xsl:if test="/xml/layout/field[@name $ieq$ context(-1)/@name]/@info" >
				<xsl:attribute name="title">
					<xsl:value-of select="/xml/layout/field[@name $ieq$ context(-1)/@name]/@info" />
				</xsl:attribute>
				</xsl:if>
				<xsl:choose>
				<xsl:when test="/xml/layout/field[@name $ieq$ context(-1)/@name]/@caption" >
					<xsl:value-of select="/xml/layout/field[@name $ieq$ context(-1)/@name]/@caption" />
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="@name" />
				</xsl:otherwise>
				</xsl:choose>
			</th>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>	

<xsl:template match="z:row">
<TR>
<xsl:for-each select="/xml/s:Schema/s:ElementType[@name='row']/s:AttributeType">
   	<xsl:choose>
		<xsl:when test="@rs:hidden" />
		<xsl:when test="/xml/layout/field[@name $ieq$ context(-1)/@name]/@visible[text() $ieq$ 'false']"/>
		<xsl:otherwise>
			<td nowrap='true'><xsl:value-of select="context(-2)/@*[nodeName()=context(-1)/@name]" /></td>
		</xsl:otherwise>
	</xsl:choose>
</xsl:for-each>
</TR>
</xsl:template>	
</xsl:stylesheet>
