Hello experts,
I am new to XSLT, SInce I am working integration project where we have XML to XML conversion using XSLT
There is one line of code which I am not understanding
<xsl:when test="following-sibling::*[2]/CreditOrDebitTransactionType='54'"/>

Can anyone explain what this code does ,
and "CreditOrDebitTransactionType" what this does , This is not field

Thanking you in Advance

1 Year
Discussion Span
Last Post by JOSheaIV

Alright let's see if can offer some help. I will admit I haven't done a lot of XSL experience myself, however, it does follow XPath logic (which I do have experience with)

The "when" works kind of like an if statement if the scenario is true, then the sub code (or nodes within), will be executed.

The "following-sibling" means the next node, on the same level as the current. So if you have say <A></A><B></B>, and executed this on "A", it would select "B". (Actually from what I can tell to use that you need following-siblings::*

But there's even more, from how I read this (and what I know of Xpath), this says that you want to select the 2nd siblings from the current node, who has a sub-node of CreditOrDebitTransactionType with a value of 54

I believe it would work like this. You have say the following XML, and you run the expression against the "A" node. If you did so the statement would be true and code in between that <when></when> would execute


I will admit this is the first time I have seen that followng-sibling, but quickly looking on Google , and what I know of Xpath, this is what I can tell from the statement.

This article shows a good example of that following-sibling logic

Edited by JOSheaIV

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.