[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: "Chris Hicks" <chrish2000@xxxxxxxxxxxxxx>
Date: Tue, 21 Dec 2004 20:25:37 +1100
xml datasets
Thanks Jarno,

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

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="idkey" match="photograph" use="id"/>
<xsl:key name="subjectkey" match="photograph" use="id"/>
<xsl:template match="/">
     <xsl:apply-templates select="results"/>
</xsl:template>

<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.

Any help would be appreciated.

Cheers,

Chris

 

> -----Original Message-----
> From: Jarno.Elovirta@xxxxxxxxx [mailto:Jarno.Elovirta@xxxxxxxxx] 
> Sent: Tuesday, 21 December 2004 7:16 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Summarising XML datasets
> 
> Hi,
> 
> > I have a problem formatting some XML I am receiving from a 
> 3rd party 
> > application that I cannot alter.
> > 
> > The application is querying a database that has a table 
> called photo 
> > and a table called photosubject, there is a one to many 
> relationship 
> > between photo and photosubject.
> 
> snip
> 
> > What I want to do if possible is to render the information 
> using xslt 
> > as:
> > 
> > HouseID  |  House  |  Description | Subjects 
> > ===========================================
> > 1        |  House  |  House 1     | X, Y, Z
> 
> XSLT 2.0 solution
> 
>   <tbody>
>     <xsl:for-each-group select="results/photograph" group-by="id">
>       <tr>
>         <td>
>           <xsl:value-of select="id"/>
>         </td>
>         <td>
>           <xsl:value-of select="name"/>
>         </td>
>         <td>
>           <xsl:value-of select="description"/>
>         </td>
>         <td>
>           <xsl:value-of select="current-group()/subject" 
> separator=", "/>
>         </td>
>       </tr>
>     </xsl:for-each-group>
>   </tbody>
> 
> See <http://www.jenitennison.com/xslt/grouping/> how to 
> achieve this using XSLT 1.0 and the Muenchian Method.
> 
> 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.