xsl-list
[Top] [All Lists]

RE: Summarising XML datasets

2004-12-21 03:08:58
Jarno, 

Thankyou very much for your help, I even managed to group to another level
now I've got my head around the concept.

Cheers,

Chris

-----Original Message-----
From: Jarno(_dot_)Elovirta(_at_)nokia(_dot_)com 
[mailto:Jarno(_dot_)Elovirta(_at_)nokia(_dot_)com] 
Sent: Tuesday, 21 December 2004 8:42 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Summarising XML datasets

Hi,

I've tried following the example from Jeni's site and come 
up with the
following:

snip

<xsl:template match="results">
    <xsl:for-each select="photograph[count(. | key('idkey', 
id)[1])=1]">
        <h3><xsl:value-of select="id" /></h3>
        <h4><xsl:value-of select="name"/></h4>
        <h5><xsl:value-of select="description"/></h5>
    <xsl:for-each select="key('subjectkey', id)">
            <TABLE border="0" width="75%">
                <tr>
                    <th width="10%" align="right">Subject</th>
                    <td width="90%" align="left"><xsl:value-of 
select="subject" /></td>
                </tr>
            </TABLE>
            <hr width="75%" align="left"/>
         </xsl:for-each>
  
    </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

This works unless I have a duplicate subject node, which 
actually can 
happen.

I'm a little bit stuck with how to only display unique subjects.

Then you need to generate a second grouping key, which is a 
concatenation of ID and subject.

  <xsl:key name="subjectkey" match="photograph" 
use="concat(id, ' ', subject)"/>

and list subjects with

  <xsl:for-each select="key('idkey', id)[generate-id(.) = 
generate-id(key('subjectkey', concat(id, ' ', subject)))]">
    <xsl:if test="not(position() = 1)">, </xsl:if>
    <xsl:value-of select="subject" />
  </xsl:for-each>

Cheers,

Jarno

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>