Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Conditionally Sum an Attribute

From: David Carlisle <davidc@--------->
To:
Date: 6/1/2008 12:59:00 AM
> 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. 
________________________________________________________________________


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent