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,'::',.))]"> ... </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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format