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

Re: RE: (Keys on multiple element types)

Subject: Re: RE: (Keys on multiple element types)
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 5 Feb 2002 14:22:04 +0000
xsl concat newline
Hi Ahmad,

> OK, so if I do
>
> <xsl:key name="rows" match="FILES/*"
>          use="concat(name(), '+', name)" />

So the key values are:

  'RECORDA+Fred'
  'RECORDA+Fred'
  'RECORDB+Fred'
  'RECORDC+Harry'

> <xsl:template match="FILES">
> <xsl:apply-templates select="*[generate-id(.) =
>     generate-id(key('rows', concat(name(), '+', name))[1])]"/>
> </xsl:template>
>
> <xsl:template match="FILES/*">
>                    <xsl:value-of select="name"/>
>                    <xsl:for-each select="key('rows', name)"> 
>                    <xsl:value-of select="$newline"/>
>                    <xsl:value-of select="project_name"/>
>                    <xsl:value-of select="$newline"/>
>                 </xsl:for-each>
> </xsl:template>

In this template you're printing the name of the selected record (i.e.
'Fred', 'Fred' and 'Harry'. Then you're trying to recover all those
records whose key value is the same as that name (e.g. those records
whose key value is simply 'Fred'). As you've seen above, the key
values are actually combinations of the name of the record element and
the name element child of the record, so you end up iterating over an
empty node set, which is why you don't get the project_names coming
out. What you wanted to do was:

  <xsl:for-each select="key('rows', concat(name(), '+', name))">
    <xsl:value-of select="$newline" />
    <xsl:value-of select="project_name" />
    <xsl:value-of select="$newline" />
  </xsl:for-each>

> I get FredFredHarry. So its removed the extra Fred but doesnt print the
> project_names. If I change this so that instead of name I group by
> project-name..thus

This had exactly the same problem as above, but was otherwise
perfectly correct as far as I could tell :)

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.