xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Newbie question - Muenchian method and XPath


Subject: [xsl] Newbie question - Muenchian method and XPath
From: "Chris Flynn" <chris@xxxxxxxxxxxxxxxxx>
Date: Tue, 22 Feb 2005 22:27:09 -0000

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
Keywords
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor