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?

2
  • 1
    Does this answer your question? How to implement if-else statement in XSLT? Commented Dec 29, 2019 at 13:59
  • you should post example xml and full code then we can understand and able to answer proper. Commented Dec 29, 2019 at 14:58

1 Answer 1

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'">
Sign up to request clarification or add additional context in comments.

2 Comments

It's succeded. Thank you very much :)
please close the question by accepting the answer if it's help you to achive your desire output. Cheers!!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.