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

Re: summing, ok

Subject: Re: summing, ok
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Sun, 13 Feb 2005 01:41:24 -0800 (PST)
match models
So you wish to count unique models.. This is a
grouping problem... (and Muenchian grouping technique
first comes to my mind)

Please try this XSL -

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
<xsl:output method="text" />    
  
<xsl:key name="by-model" match="car" use="model" />
  
<xsl:template match="/cars">
  <xsl:variable name="modelcount">
    <xsl:for-each select="car[generate-id(.) =
generate-id(key('by-model',model)[1])]">  
      1      
    </xsl:for-each>    
  </xsl:variable>

  Total no of models - <xsl:value-of
select="string-length($modelcount) -
string-length(translate($modelcount,'1',''))" />

</xsl:template>  
 
</xsl:stylesheet>

Regards,
Mukul

--- Marcos Hercules dos Santos <mhercules@xxxxxxxxx>
wrote:

> Thanks Mukul Gandhi, 
>  the stage 1 from summing  used  by exemplification
> - cars. It's all ok, cool.
> thanks
> 
> Going on,  based in the same question,  how  must do
> I to proceed to
> group a tag and totalize itself.
> 
> Using the same example:
> 
> <cars> 
>    <car>
> 		<model>V667320</model>
> 		<name>Sportage</name>
>                 <categ>sport</categ>
> 
>    </car>
>    <car>
> 		<model>M382932</model>
> 		<name>Silverado</name>
>                <categ>pick-up</categ>
>  </car>
> 
> Imagine that the first element (model) be written
> five times, the
> second model two times, and other  any model  four
> times. Supposing
> that this could be a greatest structure with 25
> models and many
> occurences to it , how to do to generate the total
> number of models
> and not  occurences
> 
> The Total number  to display =  25 
> 
> if  consider the three , then  = 3   and  not   
> 5+2+4
> 
>  
> Marcos Hercules dos Santos


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250

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.