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

Re: Conditionally Sum an Attribute

Subject: Re: Conditionally Sum an Attribute
From: David Carlisle <davidc@xxxxxxxxx>
Date: Sun, 1 Jun 2008 01:58:25 +0100
Re:  Conditionally Sum an Attribute
> I want to output "DataVox is offering Big Momma's Cafe
> project services at a fixed price for the installation of 1 router, 3
> switches, and 7 phones."

That doesn't seem to match the posted input, it's always helpful if you
say the expected result from a given input, I get



  17 Cisco phones, and 2 Cisco routers.


> <xsl:result-document href="file:///C:\Saxon\bin\proposal.html">

always use / not \ it's a URI not a windows file path.



<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
 version="2.0" >
<xsl:param name="customer">Customer</xsl:param>
<xsl:key name="sku" match="knowledge/part" use="code" />

<xsl:variable name="root" select="/"/>
<xsl:variable name="skus" as="xs:string*"
select="distinct-values(/knowledge/part/code)" />

<xsl:variable name="names" as="xs:string*">
 <xsl:for-each select="$skus">
  <xsl:variable name="x" select="document('mySkus.xml')/skus/sku[starts-with(.,current())]"/>
  <xsl:sequence select="
			key('sku',current()[$x],$root)/(concat(sum($x/@quantity),' ',name))"
		/>
 </xsl:for-each>
</xsl:variable>
<xsl:template match="/">


<xsl:result-document href="proposal.html">
 <html>
 <head>
  <title>Project Services from DataVox</title>
 </head>
 <body>
  <H1>Executive Summary</H1>
<H2>Project Services Summary</H2>
<H3>Introduction</H3>
<p>
DataVox is offering <xsl:value-of select="$customer"/> project
services at a fixed price for the installation of
<xsl:for-each select="$names">
<xsl:choose>
	<xsl:when test="position()=1">
		<xsl:value-of select="concat(' ', .)"/>
	</xsl:when>
	<xsl:when test="position()=last()">
		<xsl:value-of select="concat(', and ', ., '. ')"/>
	</xsl:when>
	<xsl:otherwise>
		<xsl:value-of select="concat(', ', .)"/>
	</xsl:otherwise>
</xsl:choose>
</xsl:for-each>

</p>

 </body>
 </html>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

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.