Lookup elements and sort

Here should go questions about transforming XML with XSLT and FOP.
undrmoons
Posts: 11
Joined: Sat Jan 14, 2006 7:17 pm
Contact:

Lookup elements and sort

Post by undrmoons » Mon Jul 09, 2012 9:33 pm

I'm having trouble finding the best way to go about solving for the following. I have an XML file which contains all of it's item level data in one location within an XML file. Everywhere else in the file, only a reference id is used.

Each time the <id> tag is used I need to perform a look up in the xml file to find all of the necessary information to finish my output. The assumption is that these <id> tags are in order, however if the items having a matching value in the <name> tag, all child nodes (other than the address) would need to be suppressed.

So my xml would look something like:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<root>
<stores>
<store>
<name id="111" rate="20">Joe's</name>
<address>11 Smith St.</address>
<theme>Joe's stuff for sale</theme>
</store>
<store>
<name id="222" rate="14">Joe's</name>
<address>12 Bob St.</address>
<theme>Joe's stuff for sale</theme>
</store>
<store>
<name id="333" rate="16">Joe's</name>
<address>13 Nancy St.</address>
<theme>Joe's stuff for sale</theme>
</store>
<store>
<name id="444" rate="18">Joe's</name>
<address>14 George Way</address>
<theme>Joe's stuff for sale</theme>
</store>
</stores>

<places>
<store>
<id>333</id>
</store>
<store>
<id>111</id>
</store>
</places>
</root>
And my resulting XML should look like:

Code: Select all

<root>
<stores>
<store>
<name>Joe's</name>
<address>11 Smith St.<rate>20</rate></address>
<address>14 George Way<rate>18</rate></address>
<address>13 Nancy St.<rate>16</rate></address>
<address>12 Bob St.<rate>14</rate></address>
<theme>Joe's stuff for sale</theme>
</store>
</stores>
</root>
Note that the <name><address>(first address) and <theme> come from the initial element. The following elements only show address if the value of the <name> element are a match. This would repeat for a number of infinite ID's...

Best approach? These files will be pretty large.

Thanks in advance!