Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Help with strategy for a peculiar muenchian grouping problem Help with strategy for a peculiar muenchian grouping problemTo: NULL Date: 6/1/2006 5:36:00 AM
Hi all,
I've got a bit of a head scratcher here.
Basically I've got an XML file with items in it like so
<item>
<name>Valuable1_a</name>
<amount>10</amount>
</item>
<item>
<name>Valuable1_b</name>
<amount>10</amount>
</item>
<item>
<name>Valuable2</name>
<amount>10</amount>
</item>
<item>
<name>Valuable2_a</name>
<amount>10</amount>
</item>
And I'm trying to roll up the amounts to leave me with
Valuable1 20
Valuable2 20
Basically I'd need to do a "group by" on unique names (excluding any
suffixes if there are any).
I've tried various ways
-Creating a temp tree and setting up a muenchian group on that
-can't seem to do this in MSXML
-Setting up to groups, one for items with second last character "_",
one for everything else
<xsl:key name="ikey1"
match="item[substring(name,string-length(name)-1,1)='_']"
use="substring(name,1,string-length(name)-2)"/>
<xsl:variable name = "unq"
select="item[generate-id(.)=generate-id(key('ikey1',substring(name,1,string-length(name)-2)))]/name\"/>\n"
and then the same but this time where the second last character != "_"
But it creates duplicates.
I can't work out how to do this given
-You can't create a muenchian group on a calculated bit of xml
-You can't seem to do a conditional i.e. (condition) ? (if true) : (if
false) type statement in the key setup
-I don't know how to combine two unique lists to create a single unique
list if there are possibly things in common between them?
Thoughts on a strategy anyone?
-Most confused Mike.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
