473,378 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

counting equal entries

Hi all,
I try to create an index page from a document. The idea behind is to
collect a certain word and list it with *all* occurences in the
document, like

foo .... 12, 23, 45
bar .... 2, 5, 88

and so on. I have a XML document which contains entries with different
classes (Java classes).
I have a XSL stylesheet which collects all entries in a sorted order.
But there is one separate entry for each occurence:

foo ... 12
foo ... 23
foo ... 45
bar ... 2

and so on.

Code follows:

<xsl:for-each select="key('index-key', $lower-alphabet)">
<xsl:sort select="@name" case-order="lower-first"/>
<xsl:call-template name="display-index-item">
<xsl:with-param name="item" select="." />
</xsl:call-template>
</xsl:for-each>

The $lower-alphabet is only a variable containing all lower letters.
How can I pass an indicator to the template "display-index-item" where
I can decide if an entry has the same name as the previous one?

TIA,
Ralf.
Jul 20 '05 #1
2 1539
> I try to create an index page from a document. The idea behind is to
collect a certain word and list it with *all* occurences in the
document, like

foo .... 12, 23, 45
bar .... 2, 5, 88

and so on. I have a XML document which contains entries with different
classes (Java classes).
I have a XSL stylesheet which collects all entries in a sorted order.
But there is one separate entry for each occurence:

foo ... 12
foo ... 23
foo ... 45
bar ... 2


Hi,

I'm not sure if this will solve the problem, but you might look at this:

Given this xml:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<occ name="foo" line="23"/>
<occ name="foo" line="12"/>
<occ name="bar" line="5"/>
<occ name="bar" line="88"/>
<occ name="foo" line="45"/>
<occ name="bar" line="2"/>
</root>

#########################
,this stylsheet:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:key name="index-key" match="occ" use="@name"/>

<xsl:template match="/">
<xsl:for-each select="//occ[generate-id(.)=generate-id(key('index-key',@name))]/@name">
<xsl:sort select="." case-order="lower-first"/>
<xsl:value-of select="."/>:
<xsl:apply-templates select="//occ[@name=current()]">
<xsl:sort select="@line" case-order="lower-first"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:template>

<xsl:template match="occ">
<xsl:value-of select="@line"/>,
</xsl:template>

</xsl:stylesheet>
########################
,will output:

bar: 2, 5, 88, foo: 12, 23, 45,
########################
Is this of any use?

--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #2
"Joris Gillis" <ro**@pandora.be> wrote in message news:<op**************@news.pandora.be>...
[...]
########################
Is this of any use?


Oh yes, thank you!

Ralf.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: mr_burns | last post by:
hi, i am wanting to count the number of unique rows under a certain column. i want to count how many times a page has been accessed. how i plan to do this is every time a page is accessed, a...
5
by: khaled Hajjar | last post by:
Hello, I have this template : <root> <categorie> <poste att = 'true'> ..... </poste> <poste att = 'false'> .....
6
by: edwardfredriks | last post by:
I'm looking for a script that, instead of counting down, can "count up" from a given date. So the output should be something like "(xx) days since (date/event)" or "(date/event) was (xx) days ago"....
1
by: mjobrien | last post by:
Thanks for the hint Allen (see below). But I am already doing that count as total records read (5)in the report footer. That count is unduplicated for the record not for the field - student ID as...
4
by: BJ | last post by:
Can anyone tell me how to include a count of group records in a group footer. I know (I think I know!) that I have to include an unbound text box in the footer, but what expressions do I use to...
7
by: MP | last post by:
Hello everyone, I am an old C++/COM programmer that converted about 8 months ago to C#/.Net, and I have no regrets. I am now converting our caching subsystem from COM to .Net and I have a...
1
by: Mr. x | last post by:
Hello, I need a script for counting the no. of enters on my site, please. I need a check that for the same user in the same day - if the user enter several times, it is count once (or something...
2
by: StevePBurgess | last post by:
Hi. I have a script that runs every night on my server that counts the hits for my hosted RSS feeds and puts the information into a MySQL table which then feeds the live(ish) statistics graphs on...
1
by: d3vkit | last post by:
Edit: Gosh I should really sleep. I was looking at my article numbers, not my ACTUAL DB numbers; seems I had deleted some blogs or something but it kept marching forward, so there was a discrepancy...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.