संपादित
पढ़ने पर आपकी पोस्ट फिर से, मुझे लगता है कि मेरे उत्तर का मूल संस्करण (नीचे) यह नहीं है।
आप एक सूची पहले से ही है - अपने चर घोषणा का चयन करता है एक नोड-सेट सभी <country>
नोड्स <Request>
के बच्चों (एक नोड-सेट एक सरणी के XSLT बराबर/एक सूची है) कर रहे हैं की:
<xsl:variable name="$country" select="Request/country" >
लेकिन बिंदु यह है कि, आप भी की आवश्यकता नहीं है जो एक अलग चर के रूप में सूचीबद्ध है; आप सभी की जरूरत है:
<xsl:when test="Request[country=$country]"><!-- … --></xsl:when>
कहाँ Request[country=$country]
के रूप में लिखा है "<Request>
के भीतर, हर <country>
को देखने और उसका चयन अगर यह $country
के बराबर है।" जब अभिव्यक्ति एक गैर-खाली नोड-सेट लौटाती है, तो $country
सूची में है।
वास्तव में, रूबेंस फरियास ने शुरुआत से क्या कहा था। :)
मूल उत्तर, रिकॉर्ड के लिए रखा गया।
<!-- instead of a variable, this could be a param or dynamically calculated -->
<xsl:variable name="countries" select="'EG, KSA, UAE, AG'" />
<xsl:variable name="country" select="'KSA'" />
<xsl:choose>
<!-- concat the separator to start and end to ensure unambiguous matching -->
<xsl:when test="
contains(
concat(', ', normalize-space($countries), ', ')
concat(', ', $country, ', ')
)
">
<xsl:text>IN</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>OUT</xsl:text>
</xsl:otherwise>
</xsl:choose>
उस सूची आपके XML इनपुट पर अंतर्गत आता है:
"सूची" से यदि आप टोकन के एक अल्पविराम से अलग स्ट्रिंग मतलब है? –
इनपुट एक्सएमएल कैसा है? क्या देश कोड टेक्स्ट नोड बच्चे हैं या तत्व या उदा। जिम्मेदार बताते हैं? –
jelovirt