[xsl] Total occurences and ordered display of XML elements

Subject: [xsl] Total occurences and ordered display of XML elements
From: Rolando Isidoro <rli@xxxxxxxxxx>
Date: Mon, 12 Sep 2005 02:55:09 +0100
Hi, I wish to present a XML dynamic generated source, from a OAI repository, which has the following structure:
http://gris-public.uninova.pt/CWIS/SPT--OAI.php?verb=ListRecords&metadataPrefix=oai_dc&set=Creator:Ricardo%20J.%20Goncalves


At this moment I have the following XSL file that performs some transformations and presents the data in HTML with only some of elements of each record being shown and being ordered by subject and then by title:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:dc="http://purl.org/dc/elements/1.1/";
xmlns="http://www.w3.org/1999/xhtml";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; exclude-result-prefixes="dc"
xmlns:def="http://www.openarchives.org/OAI/2.0/";
xmlns:xhtml="http://www.w3.org/1999/xhtml";>
<xsl:output method="html" indent="yes"/>
<xsl:param name="root"/>


<xsl:template match="/">

<xhtml:div id="body">
<link rel="stylesheet" href="{$root}/css/oai.css" type="text/css"/>
<xhtml:br/>
<xhtml:table>
<xhtml:tbody>


<xsl:for-each select="//def:record">

                       <xsl:sort select="def:metadata//dc:subject"/>
                       <xsl:sort select="def:metadata//dc:title"/>

<xhtml:tr>
<xhtml:td class="entry" bgcolor="#{substring('F5F5F5FFFFFF', (position() mod 2 * 6) + 1, 6)}">
<!-- Creator data manipulation --> <xsl:for-each select="def:metadata//dc:creator">
<xsl:value-of select="."/>
,
</xsl:for-each> <!-- Title manipulation --> <b><i>
<xsl:value-of select="def:metadata//dc:title"/>
</i></b>
.
<xhtml:br/>
<!-- Publisher manipulation --> <xsl:variable name="publisher"><xsl:value-of select="def:metadata//dc:publisher"/></xsl:variable>
<xsl:if test="$publisher!=''">
<xsl:value-of select="$publisher"/>
</xsl:if>
<!-- Date manipulation --> <xsl:variable name="date"><xsl:value-of select="def:metadata//dc:date"/></xsl:variable>
<xsl:if test="$date != '' ">
<xsl:if test="$publisher!=''">
,
</xsl:if>
<xsl:value-of select="$date"/>
.
</xsl:if>


                               <xhtml:br/>
                           </xhtml:td>
                       </xhtml:tr>

                       <xhtml:tr>
                           <xhtml:td>
                               <xhtml:br/>
                           </xhtml:td>
                       </xhtml:tr>

</xsl:for-each>

               </xhtml:tbody>
           </xhtml:table>
       </xhtml:div>
   </xsl:template>
</xsl:stylesheet>


Additionally I would like to present the number of records for each different subject and display the records according to their subject, something like:


----------------------------------------
| Authored book                    | 8 |
| Chapter in book                  | 3 |
| Papers in conference proceedings | 5 |
----------------------------------------

Authored book:
book1, ....
book2, ....
book3, ....
book4, ....
book5, ....
book6, ....
book7, ....
book8, ....

Chapter in book:
chapter4, ....
chapter7, ....
chapter9, ....

Papers in conference proceedings:
paper5, ....
paper6, ....
paper7, ....
paper8, ....
paper9, ....

Can someone lead me to a solution for this problem?
If possible, I would like that each subject on the top table would point to the position where the records from that subject are being displayed, how can I do that?


Thanks in advance, regards,
Rolando

Current Thread