copying a tag to xml output based on a condition
Posted: Wed Jun 25, 2008 11:47 pm
need help writing xsl for following problem:
the following will be input
<main>
<item>books</item>
<source>A</source>
<destination>B</destination>
<status>yes</status>
</main>
based on the values for source, destination and the text of shipQuery, present in the following xml (stored in c:\)... i will copy the status tag in output.
<shipQuery>
<item source='A' destination='B'>books</item>
<item source='Z' destination='default'>pen</item>
<item source='B' destination='A'>default</item>
</shipQuery>
here a default means dont care. (source/destination/item can be anything)
as we can see my output will be
<main>
<item>pen</item>
<source>A</source>
<destination>B</destination>
<status>yes</status>
</main>
if there is no match in the shipQuery xml,
<main>
<item>pen</item>
<source>A</source>
<destination>B</destination>
</main>
will be my output
how can this be achieved?
the following will be input
<main>
<item>books</item>
<source>A</source>
<destination>B</destination>
<status>yes</status>
</main>
based on the values for source, destination and the text of shipQuery, present in the following xml (stored in c:\)... i will copy the status tag in output.
<shipQuery>
<item source='A' destination='B'>books</item>
<item source='Z' destination='default'>pen</item>
<item source='B' destination='A'>default</item>
</shipQuery>
here a default means dont care. (source/destination/item can be anything)
as we can see my output will be
<main>
<item>pen</item>
<source>A</source>
<destination>B</destination>
<status>yes</status>
</main>
if there is no match in the shipQuery xml,
<main>
<item>pen</item>
<source>A</source>
<destination>B</destination>
</main>
will be my output
how can this be achieved?