Reputation: 411
I am getting a department_code in my xml. Here I need to check if this value belongs to pre defined dept groups if so I need to display 'Yes' Else 'No'
if dept id is in (100,200,300,400,500 long list like 170 codes) then YES else I need to send as NO
How can I check this in XSLT ?
Thanks Venk
Upvotes: 1
Views: 50
Reputation: 70638
If you define a global variable like so:
<xsl:variable name="codes" select="('100', '200', '300')" />
Then you can write your test as this:
<xsl:value-of select="if (@department_code = $codes) then 'yes' else 'no'" />
(Here I am assuming department_code
is an attribute in your XML, so you might need to adjust it if not).
See an example at http://xsltfiddle.liberty-development.net/bFDb2De
Upvotes: 1