I have a for each loop and a if condition under for loop. I want to increment the value of variable i everytime if the if condition is true. Based on value of variable i I want to implement some logic. Below is the code
<xsl:variable name="i" select="0"/>
<xsl:for-each select="Request/ModifyProductsAndPackages/NrcList/Nrc">
<xsl:variable name="typeIdNrcVar" select="TypeIdNrc"/>
<xsl:if test="count(/Request/WaiveNrcList/WaiveNrc/TypeIdNrc[text()=$typeIdNrcVar])=0">
<xsl:variable name="i" select="$i + 1"/>
<xsl:if test ="$i=1">
do something
</xsl:if>
</xsl:if>
</xsl:for-each/>
Here the value of i could not be incremented. can anyone please suggest as how should i accomplish above task. Thanks for help.
Below is xml structure
<Request>
<ModifyProductsAndPackages>
<NrcList>
<Nrc>
<TypeIdNrc>14046</TypeIdNrc>
<ServiceInternalId>98602440</ServiceInternalId>
<ServiceInternalIdResets>0</ServiceInternalIdResets>
<ViewableOnly>1</ViewableOnly>
</Nrc>
<Nrc>
<TypeIdNrc>12002</TypeIdNrc>
<ServiceInternalId>98602440</ServiceInternalId>
<ServiceInternalIdResets>0</ServiceInternalIdResets>
<ViewableOnly>1</ViewableOnly>
</Nrc>
<Nrc>
<TypeIdNrc>13006</TypeIdNrc>
<ServiceInternalId>98602440</ServiceInternalId>
<ServiceInternalIdResets>0</ServiceInternalIdResets>
<ViewableOnly>1</ViewableOnly>
</Nrc>
<Nrc>
<TypeIdNrc>14098</TypeIdNrc>
<ServiceInternalId>98602440</ServiceInternalId>
<ServiceInternalIdResets>0</ServiceInternalIdResets>
<ViewableOnly>1</ViewableOnly>
</Nrc>
</NrcList>
</ModifyProductsAndPackages>
<WaiveNrcList>
<WaiveNrc>
<TypeIdNrc>12002</TypeIdNrc>
<ServiceInternalId>98602440</ServiceInternalId>
<ServiceInternalIdResets>0</ServiceInternalIdResets>
</WaiveNrc>
<WaiveNrc>
<TypeIdNrc>13256</TypeIdNrc>
<ServiceInternalId>98602440</ServiceInternalId>
<ServiceInternalIdResets>0</ServiceInternalIdResets>
</WaiveNrc>
<WaiveNrc>
<TypeIdNrc>14046</TypeIdNrc>
<ServiceInternalId>98602440</ServiceInternalId>
<ServiceInternalIdResets>0</ServiceInternalIdResets>
</WaiveNrc>
</WaiveNrcList>
</Request>
The end result I want to achieve is NrcList = NrcList-WaiveNrcList. I want to exclude on the matching records on the basis of TypeIdNrc, ServiceInternalId, ServiceInternalIdResets Below is the result xml
<Request>
<NrcList>
<Nrc>
<TypeIdNrc>13006</TypeIdNrc>
<ServiceInternalId>98602440</ServiceInternalId>
<ServiceInternalIdResets>0</ServiceInternalIdResets>
<ViewableOnly>1</ViewableOnly>
</Nrc>
<Nrc>
<TypeIdNrc>14098</TypeIdNrc>
<ServiceInternalId>98602440</ServiceInternalId>
<ServiceInternalIdResets>0</ServiceInternalIdResets>
<ViewableOnly>1</ViewableOnly>
</Nrc>
</NrcList>
</Request>
Another approach:
$iis a certain value? what does $i mean?)