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

RE: Summarising XML datasets

Subject: RE: Summarising XML datasets
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Tue, 21 Dec 2004 11:42:08 +0200
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

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.