I have a need to look up many values in one xml which looks like:
<cat catid="some_generic_text_followed_by_something_specific1" pid="x1">
</cat>
</cat><cat catid="some_generic_text_followed_by_something_specific1" pid="x2">
</cat>
<cat catid="some_generic_text_followed_by_something_specific2" pid="x3">
</cat>
<cat catid="some_generic_text_followed_by_something_specific2" pid="x4">
</cat>
<cat catid="some_generic_text_followed_by_something_specific3" pid="x5">
</cat>
So the task is to identify words like "specific1" and "specific2" and find all pid values that belong to these multiple keywords. In this case I find x1,x2,x3,x4 but not x5.
I then have to look up another xml with many nodes:
<prod prod-id="x1">
<display-name xml:lang="x-default">some text</display-name>
</prod>
<prod prod-id="x2">
<display-name xml:lang="x-default">some more text</display-name>
</prod>
<prod prod-id="x5">
<display-name xml:lang="x-default">some text</display-name>
</prod>
and update in bulk the same text right before you see "some text" with "inserted keyword" followed by what was there. So the 1st example, it would say "inserted keyword some text". In essence, I'm prepending the text.
I can do any xslt version and will probably use some tool like XmlSpy or similar.
I did find a sort of similar question/answer here XSLT to lookup values in one XML and replace in another XML file but I don't understand xslt enough to make a modification for my example.
UPDATE
I have a minor correction to my very 1st xml above: It is actually:
<cat catid="c1">
<parent>specific1</parent>
</cat>
<cat catid="c2">
<parent>specific1</parent>
</cat>
<cat catid="c3">
<parent>specific1</parent>
</cat>
<cat catid="c4">
<parent>specific2</parent>
</cat>
<cat catid="c5">
<parent>specific2</parent>
</cat>
<cat-assign catid="c1" pid="x13"/>
<cat-assign catid="c1" pid="x14"/>
<cat-assign catid="c1" pid="x15"/>
<cat-assign catid="c2" pid="x24"/>
<cat-assign catid="c2" pid="x43"/>
<cat-assign catid="c2" pid="x44"/>
<cat-assign catid="c3" pid="x45"/>
<cat-assign catid="c4" pid="x27"/>
<cat-assign catid="c5" pid="x31"/>
<cat-assign catid="c5" pid="x32"/>
<cat-assign catid="c5" pid="x33"/>
<cat-assign catid="c5" pid="x34"/>
- I need to look for an exact match "specific1" not using contains keyword
- Then find the catid (there will be multiple)
- In the same xml, find each
- finally look up the pid used to look up another xml doc