transforming somewhat relational XML

Here should go questions about transforming XML with XSLT and FOP.
BeachBum
Posts: 1
Joined: Wed Nov 19, 2008 2:13 am

transforming somewhat relational XML

Post 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?
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: transforming somewhat relational XML

Post 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
George Cristian Bina
Post Reply