Forum Stats

  • 3,770,713 Users
  • 2,253,156 Discussions
  • 7,875,555 Comments

Discussions

How do i split and assign values in nested nodes using Assign/XSLT in BPEL SOA?

User_JU665
User_JU665 Member Posts: 37 Red Ribbon

Input-:

<input>1,2,3</input>

Required Output-:

<ABC>
  <AB>
    <result>1</result>
  </AB>
  <AB>
   <result>2</result>
  </AB>
<AB>
   <result>3</result>
  </AB>
</ABC>


Tagged:

Answers

  • Martien van den Akker
    Martien van den Akker Member Posts: 2,776 Bronze Crown

    Hi,

    You should use recursion for that. In fact, a few years ago I already wrote a blog on how to do just this: https://blog.darwin-it.nl/2018/10/recursion-in-xslt.html

    Hope this helps.

    Kind regards,

    Martien

  • User_JU665
    User_JU665 Member Posts: 37 Red Ribbon

    Hi @Martien van den Akker ,


    Thanks for your response.

    Required output -:

    <ABC>
      <AB>
        <result>1</result>
      </AB>
      <AB>
       <result>2</result>
      </AB>
    <AB>
       <result>3</result>
      </AB>
    </ABC>
    

    and the output that you mentioned in blog is


    <?xml version = '1.0' encoding = 'UTF-8'?>

    <tns:ApprovalRoute xmlns:tns="http://www.example.org/Approvals/Target" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/Approvals/Target file:/D:/Projects/2018-ODC/XSL-Demo/XSL-Demo/SOA/Schemas/Approvals-Target.xsd">

       <tns:Approver>Approver1</tns:Approver>

       <tns:Approver>Approver2</tns:Approver>

       <tns:Approver>Approver3</tns:Approver>

       <tns:Approver>Approver4</tns:Approver>

       <tns:Approver>Approver5</tns:Approver>

    </tns:ApprovalRoute>


    Actually I need to create multiple nested nodes to assign values.

    please provide your input.


    Thanks & Regards,

    Nilesh Jha

  • Martien van den Akker
    Martien van den Akker Member Posts: 2,776 Bronze Crown

    Hi Nilesh,

    Of course you should adapt my xslt to your situation. I'm not going to do that for you. As a guideline, I marked the parts you should change:

    You should change the namespaces (tns and ns0 and maybe add others).

    Replace occurences of tns:ApprovalRoute with ABC. And tns:Approver with AB. You could of course nest these with multiple elements. But this is based on the information you provide me.

    Other information to be added to the structure can be provided with additional parameters. You can even use the values of $firstItem or $restDelimitedStr in the otherwise branch, to lookup information from the source message.

    Kind regards,

    Martien