XSLT Lookups
Posted: Fri Sep 26, 2025 2:01 am
Good Morning
I have an xml document that has two fields I need to lookup in another XML and translate the values (genre and sub-genre)
This is the lookup.
<lookup>
<genre id="Entertainment" ibmsGenre="LIGHT ENTERTAINMENT">
<sub-genre id="Light Entertainment" ibmsSubGenre="OTHER LIGHT ENTERTAINMENT" />
<sub-genre id="Travel" ibmsSubGenre="TRAVEL" />
</genre>
<genre id="Drama" ibmsGenre="DRAMA">
<sub-genre id="Reality" ibmsSubGenre="REALITY DRAMA" />
<sub-genre id="Travel" ibmsSubGenre="TRAVEL" />
</genre>
<lookup>
so I can get the values out of the original XML and when I only need to translate one that is fine and I can get that to work. THe issue I can not seem to get working is foloowing
I need to get the genre from the original, loop through the subgenres under that specific genre and find the matching sub-genre.
I have only been at this XSLT for about a week so if anyone can help out with this I would greatly appreciate it.
*I am pretty sure i will need a loop inside my main loop somewhere, but all my attempts sofar do not work
** I can re-format the lookup XML as that part is not fixed, if that helps with the solution
I have an xml document that has two fields I need to lookup in another XML and translate the values (genre and sub-genre)
This is the lookup.
<lookup>
<genre id="Entertainment" ibmsGenre="LIGHT ENTERTAINMENT">
<sub-genre id="Light Entertainment" ibmsSubGenre="OTHER LIGHT ENTERTAINMENT" />
<sub-genre id="Travel" ibmsSubGenre="TRAVEL" />
</genre>
<genre id="Drama" ibmsGenre="DRAMA">
<sub-genre id="Reality" ibmsSubGenre="REALITY DRAMA" />
<sub-genre id="Travel" ibmsSubGenre="TRAVEL" />
</genre>
<lookup>
so I can get the values out of the original XML and when I only need to translate one that is fine and I can get that to work. THe issue I can not seem to get working is foloowing
I need to get the genre from the original, loop through the subgenres under that specific genre and find the matching sub-genre.
I have only been at this XSLT for about a week so if anyone can help out with this I would greatly appreciate it.
*I am pretty sure i will need a loop inside my main loop somewhere, but all my attempts sofar do not work
** I can re-format the lookup XML as that part is not fixed, if that helps with the solution