[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 19:11:54 -0600
xsl merge nodes
Have you thought about generating the XML differently (that is, if you can)?

Then you would be able to eliminate nasty merging problems in XSL.

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

-----Original Message-----
From: Joseph Silverman [mailto:yossie@xxxxxxxxxxxxxxxxx] 
Sent: Friday, March 26, 2004 6:10 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  How do I "merge" nodes based on a common key? 

I did that, and still can't get it all to work, sigh.  I will keep pushing
at it.

On Mar 26, 2004, at 4:06 PM, Pieter Reint Siegers Kort wrote:

> You are right :-)
>
> So, returning to your problem, you may want to go with the xsl:key as 
> you were doing, and grouping, but to start, the use of the key must be 
> outside the template; it is not allowed in a template.
>
> <prs/>
> http://www.pietsieg.com
> http://www.pietsieg.com/dotnetnuke
>
>
> -----Original Message-----
> From: Joseph Silverman [mailto:yossie@xxxxxxxxxxxxxxxxx]
> Sent: Friday, March 26, 2004 5:51 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  How do I "merge" nodes based on a common key?
>
> Not quite - works well, sort of.  problem is, I have lots of httpload, 
> http_load, and fetch_curl nodes in my data and need to line them up 
> ("three"
> per line).  when I use your code below, they all showed up on one VERY 
> long line.  Also, there is no attempt made to correlate matching 
> httpload, http_load, and fetch-curl nodes (based on their title 
> attribute).
> THANKS -
> Yossie
>
> On Mar 26, 2004, at 3:41 PM, Pieter Reint Siegers Kort wrote:
>
>> 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
>>
> Yossie Silverman - ENTP                   "Leave the bearded one for 
> me"
> I'NET: yossie@xxxxxxxxxxxxxx            - Flesh Gordon
> HTTP: http://www.blacksteel.com/~yossie/  B3 f- t dc g++ k++ s++ p m 
> e+
>
Yossie Silverman - ENTP                   "Leave the bearded one for me"
I'NET: yossie@xxxxxxxxxxxxxx            - Flesh Gordon
HTTP: http://www.blacksteel.com/~yossie/  B3 f- t dc g++ k++ s++ p m e+

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.