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

Newbie question - Muenchian method and XPath

Subject: Newbie question - Muenchian method and XPath
From: "Chris Flynn" <chris@xxxxxxxxxxxxxxxxx>
Date: Tue, 22 Feb 2005 22:27:09 -0000
chris flynn
Hi,
Sorry, I'm relatively new to XSLT - so it's another Muenchian Method/XPath query I'm afraid!


I have an XML file, similar to... (obviously this isn't my real data, nor real tag names...)

<group value="1">
<item type="a" name="apple" />
<item type="a" name="banana" />
<item type="c" name="carrot" />
</group>
<group value="2">
<item type="b" name="some" />
<item type="c" name="random" />
<item type="c" name="words" />
</group>

... and yes, I want to do grouping with XSLT 1.0.

I'm using an <xsl:template match="group"> and then the code from Jeni's page (http://www.jenitennison.com/xslt/grouping/muenchian.html) in there, but the output is sort of like:

"Group 1
========
a - apple, banana
c - carrot, random, words

Group 2
========
b - some"

So it's dragging all <item>s together (as xsl:key is obviously document wide and I can't use scope)., which isn't what I want! (I want:

"Group 1
==========
a - apple, banana
c - carrot

Group 2
========
b - some
c - random, words"


I've tried amending one line of the solution to:


<xsl:for-each select="item[(../@value='1') and (count(. | key('mykey', @type)[1]) = 1)]">

just to see if I can get ONLY results for group 1 which are meant to be in group 1, but even this isn't working...

I presume I've just been a bit naive with my XPath expression - could anyone explain how best to tackle this?


Many thanks,
Chris


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.