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

RE: Grouping with keys or xpath

Subject: RE: Grouping with keys or xpath
From: TSchutzerWeissmann@xxxxxxxxxxxxxxxx
Date: Fri, 4 Oct 2002 11:28:17 +0100
RE:  Grouping with keys or xpath
Hi Uffe

> 
> Hello,
> I have achived to group my xml input(see further down) to the 
> desired output (see further down) 
> with with xsl file (see further down) using xpath, but I have 
> not manage to do the same with keys and the key function. The problem
> is that the key is global for the whole document. I only want 
> to group each articlerow in one variant at time.
> Any hint/help would be appreciated
> 
> Best regards
>  
> Uffe

You can still use the Muenchian method.

If a basic key is 
	<xsl:key name="article_posn" match="nev_article_pos" use="."/>

it can be made more specific by making the "use" part a combination of the
nev_article_pos value and the id of its parent, for example.

<xsl:key name="a_row_article_posn" 
	match="nev_article_pos" 
	use="concat(generate-id(..),'::',.)"/>

then you can get the unique nev_article_pos's per article_row like so:

<xsl:template match="article_row">
	<xsl:variable name="p_id" select="generate-id(.)"/>
	<xsl:for-each select="nev_article_posn[generate-id(.) = 
		generate-id(key('a_row_article_posn',
concat($p_id,'::',.)[1])]">
		...
	</xsl:for-each>
</xsl:template>

it's a bit of a headache to look at but it's much quicker than
preceding-sibling.

Tom

 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.