I want to process two separate nodes in for each in xsl.
Here's the xml:
<root>
<demomain>
<demo>
<name>A</name>
<price>10</price>
</demo>
<demo>
<name>B</name>
<price>15</price>
</demo>
<demomain>
<demomainOrig>
<demoOrig>
<name>A</name>
<price>20</price>
</demoOrig>
<demoOrig>
<name></name>
<price>25</price>
</demoOrig>
</demomainOrig>
</root>
And the xsl I have made so far is
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<demos>
<xsl:for-each select="root/demomain/demo">
<xsl:variable name="newNode" select="."/>
<Demo>
<productID id="{$newNode/name}"/>
<xsl:for-each select="root/demomainOrig/demoOrig">
<price newVal="{$newNode/price}" origVal="{price}" />
</xsl:for-each>
</Demo>
</xsl:for-each>
</demos>
</xsl:template>
</xsl:stylesheet>
Following is the output that I want:
<?xml version="1.0" encoding="UTF-8"?>
<demos>
<Demo>
<productID id="A"/>
<price newVal="10" origVal="20"/>
</Demo>
<Demo>
<productID id="B"/>
<price newVal="15" origVal="25"/>
</Demo>
</demos>
The problem is in the ier for each. If I remove the ier for each i get the price tag in output else it is not even displayed. And so I'm not able to get the original price for the particular item. I tried other questions' solutions too on stackoverflow which I found. But didn't get what I was looking for. Please Help.
Thanks in Advance
