|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: summing, ok
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








