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

Re: Problem with sum values with double param

Subject: Re: Problem with sum values with double param
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Wed, 05 Aug 2009 15:52:42 +0200
Re:  Problem with sum values with double param
Jacek Dunia wrote:

<Calls>
	<Row NR="1">
		<Rc>InTime</Rc>
		<WorkTime>20</WorkTime>
		<TechnicianName>Norman</TechnicianName>
		<ProblemType>INCYDENT</ProblemType>
	</Row>
	<Row NR="2">
		<Rc>OutTime</Rc>
		<WorkTime>10</WorkTime>
		<TechnicianName>Peter</TechnicianName>
		<ProblemType>INCYDENT</ProblemType>
	</Row>
	<Row NR="3">
		<Rc>InTime</Rc>
		<WorkTime>150</WorkTime>
		<TechnicianName>Norman</TechnicianName>
		<ProblemType>FAILURE</ProblemType>
	</Row>
	<Row NR="4">
		<Rc>OutOfTime</Rc>
		<WorkTime>10</WorkTime>
		<TechnicianName>Norman</TechnicianName>
		<ProblemType>RemoteAccess</ProblemType>
	</Row>
	<Row NR="5">
		<Rc>InTime</Rc>
		<WorkTime>20</WorkTime>
		<TechnicianName>Norman</TechnicianName>
		<ProblemType>INCYDENT</ProblemType>
	</Row>
	<Row NR="6">
		<Rc>InTime</Rc>
		<WorkTime>20</WorkTime>
		<TechnicianName>Peter</TechnicianName>
		<ProblemType>INCYDENT</ProblemType>
	</Row>
I would like get following out put
Name	TotalWorkTimeByIncydent	TotalWorkTimeByFailure	TotalWorkTime	InTime	OutOfTime
Peter		30			0			30	1	1	
Norman		40			150			200	2	1	

Thecnican name can't be duplicate so I make like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<xsl:key name="list" match="/Activities/Row" use="TechnicianNames" />

The root element you show in your XML sample is named 'Calls', not 'Activities' so I would expect match="Calls/Row".


<xsl:template match="Activities">

Same here, shouldn't that be match="Calls"?


		<html>
			<body>
				<xsl:variable name="var_TechnicianNamess"
select="/Activities/Row[count(. | key('list', TechnicianName)[1]) =
1]"/>
				<xsl:for-each select="$var_TechnicianNamess">
					<xsl:value-of select="TechnicianName" />
					<xsl:value-of select="sum(WorkMinute)" />

I think you want
<xsl:value-of select="sum(key('list', TechnicianName)/WorkMinute)"/>


to sum up the WorkMinute(s) for each Technician.




--


	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

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.