<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:output method="html"/>	
		
	<!-- Primary template to descend down XML provided by Message Queue -->
	<!-- HTML elements are provided here to begin building the HTML page to be generated by the transformation -->
	<xsl:template match="Messages">							
							
		<table>			
			
			<!-- Add message details to table -->				
			<xsl:apply-templates select="Message"/>						
							
		</table>
		<BR/>			
			
	</xsl:template>		
	
	<!-- This template gets each row/record from the business object -->
	<xsl:template match="Message">
	   <xsl:variable name="MessageID" select="@ID"/>				
		  <xsl:for-each select="*">
			<xsl:choose>
			  <xsl:when test="position()=1">
			    <tr>
				  <td>	
				    <input type="button">			     
				       <xsl:attribute name="OnMouseOver"><xsl:value-of select="$MessageID"/><xsl:text>.style.display='block'</xsl:text></xsl:attribute>
				       <xsl:attribute name="OnMouseOut"><xsl:value-of select="$MessageID"/><xsl:text>.style.display='none'</xsl:text></xsl:attribute>
				       <xsl:attribute name="value"><xsl:text>+</xsl:text></xsl:attribute>
				    </input>
				   </td>
				   <td>		        			        
					<font color="RED">      							
				        <xsl:value-of select="text()"/>
					</font>			
			       </td>
			    </tr>
			  </xsl:when>			  
			  <xsl:otherwise>
			  	<tr>
			  	  <table bgcolor="#FFFFFF" cellspacing="1" width="100%" style="display:none">
			  	    <xsl:attribute name="id"><xsl:value-of select="$MessageID"/></xsl:attribute>
			  	    
			  	    <xsl:for-each select="*">
			  	      <tr>
			  	      <td valign="top"><xsl:value-of select="name()"/>: </td>
	                  <td valign="top">
			          <xsl:value-of select="text()"/>
	                  </td>
	                  </tr>
	                </xsl:for-each>
	              </table>
	            </tr>
			  </xsl:otherwise>
			</xsl:choose>			
		  </xsl:for-each>		
	</xsl:template>	
	
	<xsl:template match="DetailsTable">
		<table id="item1list" class="list" width="60" border="1" style="display:none">		
	      <xsl:apply-templates select="MessageDetails"/>
	    </table>
	</xsl:template>	
	
	<xsl:template match="MessageDetails">
	   <tr bgcolor="#FFFFFF">
	     <td>
			<xsl:value-of select="text()"/>
	     </td>
	   </tr>
	</xsl:template>

</xsl:stylesheet>

