Page 1 of 1

transforming somewhat relational XML

Posted: Wed Nov 19, 2008 2:30 am
by BeachBum
I've got some XML that links nodes with an ID of sorts but I need to put them together... The XML is somewhat propriatary so I can't post an actual sample (or someone will come and kill me in the night ... lol) but here is an idea of what I'm dealing with:

Code: Select all


<searchReply>
<index>
<group>
<proposal><ref>1</ref></proposal>
<date>051208</date>
</group>
<group>
<proposal><ref>2</ref></proposal>
<date>071208</date>
</group>
</index>
<proposals>
<recommendation>
<itemNumber><number>1</number></itemNumber>
<priceDetail><amount>14.50</amount></priceDetail>
</recommendation>
<recommendation>
<itemNumber><number>1</number></itemNumber>
<priceDetail><amount>12.50</amount></priceDetail>
</recommendation>
<recommendation>
<itemNumber><number>2</number></itemNumber>
<priceDetail><amount>16.50</amount></priceDetail>
</recommendation>
<recommendation>
<itemNumber><number>2</number></itemNumber>
<priceDetail><amount>18.50</amount></priceDetail>
</recommendation>
</proposals>
</searchReply>
So, what I need to do is relate the index/group/proposal/ref to the recommendation/itemNumber/number so I could output:

05/12/08 $14.50
05/12/08 $12.50
07/12/08 $16.50
07/12/08 $18.50

I can't come up with a way to do that? any ideas?

Re: transforming somewhat relational XML

Posted: Tue Nov 25, 2008 6:46 pm
by george
Look at xsl:key. That allows you to identify a set of notes for a specific value. It is basically a hashtable that for a given value gives you the set of nodes that match that value.

Hope that helps,
George