mercredi 28 mars 2018

How to change element value by comparing another xml using xslt

I have below xml 1 and xml2. I want compare </publication> from xml1 with xml2 and update <price> in xml1 with the value present in xml2.Please help me out,I have stored whole xml2 in one variable and parse through it inside a template which looks for match="book" its adding new tag inside but not updating existing one.

XML-1

<books>
<book>
<name>abc</name>
<publication>triangle</publication>
<price></price>
</book>
<book>
<name>def</name>
<publication>rectangle</publication>
<price></price>
</book>
</books>

xml-2

<resource>
<prices>
<publication>triangle</publication>
<price>100</price>
<prices>
<prices>
<publication>rectangle</publication>
<price>200</price>
<prices>
</resource>

expected output

<books>
    <book>
    <name>abc</name>
    <publication>triangle</publication>
    <price>100</price>
    </book>
    <book>
    <name>def</name>
    <publication>rectangle</publication>
    <price>200</price>
    </book>
    </books>




Aucun commentaire:

Enregistrer un commentaire