A grouping question everybody asks... a good 'grouping' solution:
http://www.jenitennison.com/xslt/grouping/muenchian.html
Joseph Silverman wrote:
I have a xml file I would like to process into a html table. I figure
that xslt is the way to go. The file contains various nodes (results
from load testing) that all share a single attribute, title, that
identifies and links them in groups. See snippet below.
So, I can't figure out some code to process this file and "merge" the
nodes based on the title attribute so I can print each "merged" node as
a single line in a table. sub-nodes AS well as attributes (though there
is no overlap in the latter!) should be merged. Then I can use a
<xsl:for-each ..> to process the merged list.
I tried some stuff on my own and it is getting me nowhere (see below).
Any ideas?
Thanks - Yossie
<run>
<http_load title="X">
<url>http://delenn-g:8080/lps/sample-apps/calendar/calendar.lzo?
lzt=swf</url>
<rr>delenn-g</rr>
<fetches>94851</fetches>
<max_parallel>50</max_parallel>
<mbytes>111.443</mbytes>
<elapsed>180.406</elapsed>
<mean_kbytes_connection>1.20312</mean_kbytes_connection>
<fetches_sec>525.763</fetches_sec>
<mbytes_sec>0.617733</mbytes_sec>
<msec_connect_mean>0.400405</msec_connect_mean>
<msec_connect_max>66.577</msec_connect_max>
<msec_connect_min>0.211</msec_connect_min>
<msec_first_mean>94.5393</msec_first_mean>
<msec_first_max>3768.62</msec_first_max>
<msec_first_min>2.111</msec_first_min>
<http_result>
<code>404</code>
<count>94851</count>
</http_result>
</http_load>
<httpload gzip="true"
title="X"
seconds="180"
path="/sample-apps/calendar/calendar.lzo?lzt=swf"
parallel="50"
cache="false"
lps="lps"
datapath=""
backend="" />
<fetch-curl title="X">
<url>http://delenn-g:8080/lps/sample-apps/calendar/calendar.lzo?
lzt=swf</url>
<status>HTTP/1.1 404 Not Found</status>
<size>1232</size>
<http-headers>
<Date>Wed, 24 Mar 2004 19:04:12 GMT</Date>
<Server>Jetty/4.2.17 (Linux/2.4.18-26.8.0 i386
java/1.4.1_02)</Server>
<Content-Type>text/html</Content-Type>
<Content-Length>1232</Content-Length>
</http-headers>
</fetch-curl>
<!--
...
... more httpload, http_load, fetch-curl nodes with different title
attributes, no more than one of each with a given title.
...
-->
</run>
---
<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">
<xsl:key name="bleh" match="http_load | httpload | fetch_curl"
use="@title" />
<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>
<xsl:for-each select="key('bleh',.)">
<tr>
<td><xsl:value-of select="@title"/></td>
<td><xsl:value-of select="@cache"/></td>
<td><xsl:value-of select="@gzip"/></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>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
--+------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--