Concatenate XML in BPEL 2.0 — oracle-tech

    Forum Stats

  • 3,701,013 Users
  • 2,239,261 Discussions
  • 7,834,972 Comments

Discussions

Concatenate XML in BPEL 2.0

ArijitKumarArijitKumar Posts: 6
edited April 2018 in SOA Suite Discusssions

Hi All,

Need your help for a requirement in BPEL 2.0. I have a collection in the below format

<FilesCollection>

      <Files>

        <transactionid>

        <status>

        <filename>

      <Files>

<FilesCollection>

I would be getting several such collections while traversing through a ForEach loop.

Once I have exited the loop , I need to concatenate all the collections so that finally I get something as below

<FilesCollection>

          <Files>

            <transactionid>

            <status>

            <filename>

          <Files>

          <Files>

            <transactionid>

            <status>

            <filename>

          <Files>

          <Files>

            <transactionid>

            <status>

            <filename>

          <Files>

<FilesCollection>

Please note that the number of FilesCollection element and the number of Files element appearing within it would be dynamic.

Thanks,

Arijit

Tagged:
ArijitKumarAnkit kalanoria

Answers

  • Ankit kalanoriaAnkit kalanoria Posts: 107
    edited April 2018

    Hello Arijit,

    I think you should use xsl to do intermediate transformation as per your desired structure for better performance and then have for loop based on that modified XML in your BPEL flow. If i understood correctly, then you want to combine all repetiive <Files> element present inside various <FileCollection> element into single :FileCollection with reptitive Files". If so then have a look at below:

    XSL:

    <xsl:template match="/">

          <ns0:IteratorPOC>

             <xsl:if test="count(/ns0:IteratorPOC/ns0:FileCollection) > 0">

                <ns0:FileCollection>

                   <xsl:for-each select="/ns0:IteratorPOC/ns0:FileCollection/ns0:Files">

                      <ns0:Files>

                         <ns0:transactionId>

                            <xsl:value-of select="ns0:transactionId"/>

                         </ns0:transactionId>

                         <ns0:Status>

                            <xsl:value-of select="ns0:Status"/>

                         </ns0:Status>

                         <ns0:Filename>

                            <xsl:value-of select="ns0:Filename"/>

                         </ns0:Filename>

                      </ns0:Files>

                   </xsl:for-each>

                </ns0:FileCollection>

             </xsl:if>

          </ns0:IteratorPOC>

       </xsl:template>

    Source:

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

    <IteratorPOC xmlns="http://xmlns.oracle.com/SOASpace/AdfConnectionPOC/ADFConnectionPOCBPELProcess">

       <FileCollection>

          <Files>

             <transactionId>transactionId1314</transactionId>

             <Status>Status1315</Status>

             <Filename>Filename1316</Filename>

          </Files>

       </FileCollection>

       <FileCollection>

          <Files>

             <transactionId>transactionId1323</transactionId>

             <Status>Status1324</Status>

             <Filename>Filename1325</Filename>

          </Files>

          <Files>

             <transactionId>transactionId1326</transactionId>

             <Status>Status1327</Status>

             <Filename>Filename1328</Filename>

          </Files>

       </FileCollection>

       <FileCollection>

          <Files>

             <transactionId>transactionId1332</transactionId>

             <Status>Status1333</Status>

             <Filename>Filename1334</Filename>

          </Files>

          <Files>

             <transactionId>transactionId1335</transactionId>

             <Status>Status1336</Status>

             <Filename>Filename1337</Filename>

          </Files>

          <Files>

             <transactionId>transactionId1338</transactionId>

             <Status>Status1339</Status>

             <Filename>Filename1340</Filename>

          </Files>

       </FileCollection>

    </IteratorPOC>

    Target:

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

    <ns0:IteratorPOC xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns0="http://xmlns.oracle.com/SOASpace/AdfConnectionPOC/ADFConnectionPOCBPELProcess">

       <ns0:FileCollection>

          <ns0:Files>

             <ns0:transactionId>transactionId1314</ns0:transactionId>

             <ns0:Status>Status1315</ns0:Status>

             <ns0:Filename>Filename1316</ns0:Filename>

          </ns0:Files>

          <ns0:Files>

             <ns0:transactionId>transactionId1323</ns0:transactionId>

             <ns0:Status>Status1324</ns0:Status>

             <ns0:Filename>Filename1325</ns0:Filename>

          </ns0:Files>

          <ns0:Files>

             <ns0:transactionId>transactionId1326</ns0:transactionId>

             <ns0:Status>Status1327</ns0:Status>

             <ns0:Filename>Filename1328</ns0:Filename>

          </ns0:Files>

          <ns0:Files>

             <ns0:transactionId>transactionId1332</ns0:transactionId>

             <ns0:Status>Status1333</ns0:Status>

             <ns0:Filename>Filename1334</ns0:Filename>

          </ns0:Files>

          <ns0:Files>

             <ns0:transactionId>transactionId1335</ns0:transactionId>

             <ns0:Status>Status1336</ns0:Status>

             <ns0:Filename>Filename1337</ns0:Filename>

          </ns0:Files>

          <ns0:Files>

             <ns0:transactionId>transactionId1338</ns0:transactionId>

             <ns0:Status>Status1339</ns0:Status>

             <ns0:Filename>Filename1340</ns0:Filename>

          </ns0:Files>

       </ns0:FileCollection>

    </ns0:IteratorPOC>

    IteratorPOC was element based on quick xsd i created in my local, you change it as per your actual element.

    Hope this helps.

    Regards,

    Ankit k

    ArijitKumarArijitKumar
  • ArijitKumarArijitKumar Posts: 6
    edited April 2018

    Hi Ankit ,

    Thanks for your reply.

    The difficulty I am having is how to prepare my source for the xslt that you have given in your example i.e. what intermediate transformation needs to be done so that I can combine the several FileCollection elements and prepare the source for the final xslt.

    Thanks,

    Arijit

  • ArijitKumarArijitKumar Posts: 6
    edited April 2018

    Hi Ankit ,

    Thanks for your reply.

    The difficulty I am having is how to prepare my source for the xslt that you have given in your example i.e. what intermediate transformation needs to be done so that I can combine the several FileCollection elements and prepare the source for the final xslt.

    Thanks,

    Arijit

  • Ankit kalanoriaAnkit kalanoria Posts: 107
    edited April 2018

    Hello,

    You can try to create a temporary xsd based on below and have global variable created based on it:

    <element name="IteratorPOC">

        <complexType>

          <sequence>

            <element name="FileCollection" minOccurs="0" maxOccurs="unbounded">

              <complexType>

                <sequence>

                  <element name="Files" minOccurs="0" maxOccurs="unbounded">

                    <complexType>

                      <sequence>

                        <element name="transactionId" type="string" minOccurs="0"/>

                        <element name="Status" type="string" minOccurs="0"/>

                        <element name="Filename" type="string" minOccurs="0"/>

                      </sequence>

                    </complexType>

                  </element>

                </sequence>

              </complexType>

            </element>

          </sequence>

        </complexType>

      </element>

    Then inside your for loop of BPEL, insert your current collection into this variable by using assign activity. Map source and target within assign activity and then right click on it, you will see change rule type and there you will see append type. You can try to fit that into your purpose.

    All these are different different ways(1 i mentioned earlier and one now) to achieve that kind of requirement. Depending on your business requirement and source input structure you can choose among them. 

    Regards,

    Ankit K

    ArijitKumarArijitKumar
  • Martien van den AkkerMartien van den Akker Posts: 2,756 Bronze Crown
    edited April 2018

    Hi,

    Try the bpelx:append copy rule in the assing: https://docs.oracle.com/middleware/1221/soasuite/develop/GUID-C12BDA1F-8A7F-4963-AD5C-2A647BB02BA8.htm#SOASE396

    Add a append-copy rule for each collection (or loop over the collections). Then in the from select all the Files from the from filecollection. Then in the to select FilesCollection element of the target collection variable.

    That should do the job.

    Regards,

    Martien

    ArijitKumarArijitKumar
  • ArijitKumarArijitKumar Posts: 6
    edited April 2018

    Hi Martien ,

    Your suggestion worked. Thanks a lot.

    Thanks

    Arijit

  • Martien van den AkkerMartien van den Akker Posts: 2,756 Bronze Crown
    edited April 2018

    Thanks for the feedback. Glad to be of any help.

    Would appreciate if you could mark the discussion answered with my answer: gives me another level...

    (Although I shouldn't ask for it... )

    Ankit kalanoria
This discussion has been closed.