0

I have a xslt document. And i want use if statement in this document. My code is:

<xsl:for-each select="cbc:ProfileID"> 
    <xsl:apply-templates/>

    <xsl:if test="cbc:ProfileID='code1'">
        <xsl:text>A</xsl:text>
    </xsl:if>
    <xsl:if test="cbc:ProfileID='code2'">
        <xsl:text>B</xsl:text>
    </xsl:if>

</xsl:for-each>

I want if returned value is code1 then write A and if returned value is code2 then write B.

How can i do this?

  • 1
    Does this answer your question? [How to implement if-else statement in XSLT?](https://stackoverflow.com/questions/13622338/how-to-implement-if-else-statement-in-xslt) – stud3nt Dec 29 '19 at 13:59
  • you should post example xml and full code then we can understand and able to answer proper. – Amrendra Kumar Dec 29 '19 at 14:58

1 Answers1

0

As i can understand you are already in the same context by for-each so you need to use . in if condition like below:

<xsl:if test="normalize-space(.)='code1'">

or

<xsl:if test=".='code1'">
Amrendra Kumar
  • 1,806
  • 1
  • 7
  • 17