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

Creating a Place index

Subject: Creating a Place index
From: "Netsonic" <kaarle.kaila@xxxxxx>
Date: Mon, 24 Nov 2003 17:23:52 +0200
xsl for each index
hello there,

I did get help from here earlier on
creating an index from my report xml-file.
Now I would need some more help on the matter.

My xml-file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<raport>
<tables>
<table number="1">
<section gen="0" type="PARE">
<person> <name><givenname>Lars </givenname><surname>Schalin</surname></name>
<notices>
<notice tag="BIRT">Syntynyt <date value="17540101">01.01.1754</date>
<place name="Hanebo">Hanebo</place>. </notice>
<notice tag="DEAT">Kuollut <date value="18081010">10.10.1808</date>
<place name="Vaasa">Vaasa</place>. </notice>
</notices>
</person>
</section>
.............

<section gen="1" type="PARE"><person>
.....
</person>
</section>
</table>
</tables>
</raport>


I am now trying to create a place index from this data.
place elements are located inside table elements and it is possible
that there are more than one place index in the same table.
e.g. person was born and he died in the same place.

In the place index I want each table number where it is found only once.
I have succeeded with the xslt-file below to create a place index but I have
not succeeded
to remove the double table references.

I assume it should be done by grouping using the muenchian method the same
way as I grouped the places as I have tried here. Can anybody help me with
this?


----------------------
<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
>
<xsl:key name="contacts-by-place" match="//place" use="@name" />
<xsl:key name="index-by-table" match="ancestor::table" use="@number" />
<xsl:template match="raport">

<html>
<head>
<title>suku-testiraportti</title>

</head>
<body>
<h1>Paikkahakemisto (fi)</h1>
<table border="1">
<tr><td align="left">Place</td><td align="left">Table</td></tr>

<xsl:for-each select="//place[count(. | key('contacts-by-place', @name)[1])
= 1]">
<xsl:sort select="@name" lang="fi"/>

<tr><td align="left"><xsl:value-of select="@name" />:
<xsl:value-of select="key('contacts-by-place', @name)" />:</td><td>
<xsl:for-each select="key('contacts-by-place',@name)">
<xsl:for-each select="ancestor::table[count(. | key('index-by-table',
@number)[1]) = 1]">

<xsl:sort select="ancestor::table/@number" />
<xsl:value-of select="@number" />

</xsl:for-each>
</xsl:for-each>
</td></tr>
</xsl:for-each>

</table>
</body>
</html>

</xsl:template>

</xsl:stylesheet>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.