0

Hi,

Its bit urgent!

Can someone please show me how to use nested loop.

I have following XML file. I need to print amount in minus if any of the ApplicationReply value is credit, else the Amount should be positive.

<xsl:for-each select="Reply/ApplicationReplies/ApplicationReply[@Name='credit']">

<xsl:if test="position() = 1">

<xsl:value-of select="concat($sep, $sign, /Reply/Amount,$sep)"/>

</xsl:if>

</xsl:for-each>

It prints -Amount if Name is credit.

How do i get else? if its not credit?

<Reply>
   <ApplicationReplies>
	<ApplicationReply Name="auth">
	 	<RCode>1</RCode>
		<RFlag>SOK</RFlag>
		<RMsg>successfully.</RMsg>
	</ApplicationReply>
	<ApplicationReply Name="bill">
		<RCode>1</RCode>
		<RFlag>SOK</RFlag>
		<RMsg>successfully.</RMsg>
	</ApplicationReply>
	<ApplicationReply Name="credit">
		<RCode>1</RCode>
		<RFlag>SOK</RFlag>
		<RMsg>successfully.</RMsg>
	</ApplicationReply>
  </ApplicationReplies>
  
  <amount> 100 <amount>
</Reply>
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by pritaeas
0
<xsl:for-each select="Reply/ApplicationReplies/ApplicationReply">
	<xsl:choose>
		<xsl:when test="@Name='credit'">
			<xsl:value-of select="concat($sep, $sign, /Reply/Amount, $sep)"/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="concat($sep, /Reply/Amount, $sep)"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:for-each>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.