Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl:choose versus xsl:if Which one to use??? 1

Status
Not open for further replies.

aswolff

Programmer
Jul 31, 2006
100
US
I have an inbound xml document that needs to be converted based on logical condition:

IF
<LOCATION>50101</LOCATION>
<CLIENT_ID>1151</CLIENT_ID>
ON SOURCE DOCUMENT

THEN TARGET DOCUMENT:
<SITE_ID>KNJ<SITE_ID>

How can I create this in xsl? Not sure if I need to use:
xsl:if or xsl:choose?



Thank You.
 
Since xsl:if has no xsl:else, xsl:choose is probably the better choice.

Now perhaps I am not understanding your question. Are you really asking about a compound conditional statement?

Tom Morrison
 
Yes a conditional "AND"....do I nest them as below?

<xsl:choose>
<xsl:when test="LOCATION='50101'">
<xsl:when test="CLIENT_ID='1151'">
<xsl:text>KNJ</xsl:text>
</xsl:when>
</xsl:when>
</xsl:choose>


Thanks!!!
 
No that won't work very well!

You may simply do this:
Code:
<xsl:if test="LOCATION='50101' and CLIENT_ID='1151'">
  <xsl:text>KNJ</xsl:text>
</xsl:if>
The value of the test attribute of the xsl:if instruction is a boolean expression, so and and or are available as expected.

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top