This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

create multiple tables using a single XSL stylesheet?


Hi...

I want to output two tables. The first for source data which refers to a
room (e.g., a reception room) and the second for data from the same source
which refers to a person (e.g., an employee). Both categories are found
within the same XML source but need to be placed in separate tables. made an
attempt using the XSL below, but this fails... Help!

- Geertjan Wielenga



<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/">
		<html>
			<head>
				<title>Amsterdam Office List</title>
			</head>
			<body>
				<font color="red"><h1>Amsterdam Office
List</h1></font>
				<xsl:apply-templates/>
			</body>
		</html>	
	</xsl:template>		
	
	<xsl:template match ="LIST">
	
			<h2>Employee List</h2>
			
			
			<xsl:choose>
				<xsl:when test="LIST/EMPLOYEE/ITEM[1][.='a
room']">
					<table border="1"><font
color="green"></font>			
						<tr>
						<th>Department</th>
						<th>Room title</th>
						<th>Room number</th>
						<th>Phone</th>
						<th>Initials</th>
						</tr>
					</table>
				</xsl:when>
				<xsl:otherwise>
				<table border="1"><font
color="green"></font>
						<tr>
						<th>Department</th>
						<th>Surname</th>
						<th>First name</th>
						<th>Room number</th>
						<th>Phone</th>
						<th>Initials</th>
						</tr>
				</table>	
				</xsl:otherwise>
			</xsl:choose>			
					<xsl:apply-templates
select="EMPLOYEE">
						<xsl:sort select="ITEM[2]"/>
					</xsl:apply-templates>
	</xsl:template>		
		
	<xsl:template match="EMPLOYEE">
		<tr>
			<td><font color="red"><xsl:value-of
select="ITEM[6]"/></font></td>
			<td><font color="red"><xsl:value-of
select="ITEM[1]"/></font></td>
			<td><font color="red"><xsl:value-of
select="ITEM[2]"/></font></td>
			<td><font color="red"><xsl:value-of
select="ITEM[4]"/></font></td>
			<td><font color="red"><xsl:value-of
select="ITEM[3]"/></font></td>
			<td><font color="red"><xsl:value-of
select="ITEM[5]"/></font></td>
		</tr>	
	</xsl:template>

</xsl:stylesheet>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]