[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: How do I "merge" nodes based on a common key?

Subject: RE: How do I "merge" nodes based on a common key?
From: Pieter Reint Siegers Kort <pieter.siegers@xxxxxxxxxxx>
Date: Fri, 26 Mar 2004 17:41:30 -0600
merge td
Hi Jopseph,

Take a look at the following xsl, which does not use a key but uses three
different templates, and processes those three different templates within
one row for your table. The key to this is using <xsl:apply-templates>. The
XSL is:

<xsl:stylesheet version = '1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output method="html" encoding="UTF-8" indent="yes" />

<xsl:template match="/run">
	<html>
	<head>
	<title>Title</title>
	</head>
	<body>
	<table border="1" cellpadding="6">
	<tr>
	<th>Title</th>
	<th>Cache</th>
	<th>Gzip</th>
	<th>Fetches</th>
	<th>Parallel</th>
	<th>Mbytes/Sec</th>
	</tr>
	<tr>
	<xsl:apply-templates select="http_load" />
	<xsl:apply-templates select="httpload" />
	<xsl:apply-templates select="fetch-curl" />
	</tr>
	</table>
	</body>
	</html>
</xsl:template>

<xsl:template match="http_load" >
	<td><xsl:value-of select="@title"/></td>
	<td><xsl:value-of select="fetches/text()"/></td>
	<td><xsl:value-of select="max_parallel/text()"/></td>
	<td><xsl:value-of select="mbytes_sec/text()"/></td>
</xsl:template>

<xsl:template match="httpload" >
	<td><xsl:value-of select="@cache"/></td>
	<td><xsl:value-of select="@gzip"/></td>
</xsl:template>

<xsl:template match="fetch-curl" >
</xsl:template>

</xsl:stylesheet>

This XSL outputs the following when using your XML:

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Title</title>
</head>
<body>
<table border="1" cellpadding="6">
<tr>
<th>Title</th>
<th>Cache</th>
<th>Gzip</th>
<th>Fetches</th>
<th>Parallel</th>
<th>Mbytes/Sec</th>
</tr>
<tr>
<td>X</td>
<td>94851</td>
<td>50</td>
<td>0.617733</td>
<td>false</td>
<td>true</td>
</tr>
</table>
</body>
</html>

Note that you did not specify data to extract from the node-set 'fetch-curl'
so that's why the template is an empty one. You can now add any element or
attribute as you like.

Hope this helps you in the right direction :-)

<prs/>
http://www.pietsieg.com
http://www.pietsieg.com/dotnetnuke

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.