7 Replies Latest reply on Oct 17, 2018 1:51 PM by Martien van den Akker

    Extract delimited text in Oracle BPM

    Robinson J

      Hi Experts

       

      I have a payload within the BPM Process where a webservice returns me a list of approvers ex: tom,lee,Ben which are basically users. My requirement is to extract these users individually and assign to a node which is like target node below

       

      Source Node

      <xs:complexType name="approvalRouteByInvoiceNatureResponse">

          <xs:complexContent>

            <xs:extension base="tns:messageValueObject">

              <xs:sequence>

                <xs:element type="xs:string" name="approvalRoute" minOccurs="0"/>

                <xs:element type="xs:boolean" name="autoApprove" minOccurs="0"/>

                <xs:element type="tns:integrationResponse" name="integrationResponse" minOccurs="0"/>

                <xs:element type="tns:statusResponse" name="statusResponse" minOccurs="0"/>

              </xs:sequence>

            </xs:extension>

          </xs:complexContent>

        </xs:complexType>

       

      and the target node would look like

       

      <?xml version="1.0" encoding="windows-1252" ?>

      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"

                  xmlns="http://www.example.org"

                  targetNamespace="http://www.example.org"

                  elementFormDefault="qualified">

        <xsd:element name="ApprovalRoute">

          <xsd:complexType>

          <xsd:sequence>

          <xsd:element name="Approvers" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>

          </xsd:sequence>

          </xsd:complexType>

        </xsd:element>

      </xsd:schema>

       

      The reason being i would like to do some logic on each user,what will be the best way to get the individual users from the webservice ,

       

      Thanks for Help

      Robin

        • 1. Re: Extract delimited text in Oracle BPM
          Martien van den Akker

          Hi,

           

          You can transform them directly, using an XSLT. But, if you want to loop over the elements, and perform an action approver by approver, you should create a loop with a loop counter that selects each approver into a variable. Take a look at this article where I describe how I did it in PCS: https://blog.darwin-it.nl/2017/07/process-cloud-service-and-how-to-loop.html It works exactly the same way in BPM.

           

          Regards,
          Martien

          • 2. Re: Extract delimited text in Oracle BPM
            d465f42a-f285-4724-b7d9-9bbf75085cf4

            With Metastorm BPM v7 becoming 'Past Maintenance' in January 2018, users left on versions previous to the current OpenText MBPM v9, will run an ever-increasing risk that changes to their applications, infrastructure or operating systems will cause issues in business-critical BPM solutions.

            • 3. Re: Extract delimited text in Oracle BPM
              Martien van den Akker

              I'm sorry, but what does this have to do with the question? How is this related to Oracle BPM Suite?

               

              Regards,
              Martien

              • 4. Re: Extract delimited text in Oracle BPM
                Robinson J

                Hi,

                Thanks for the help but in your case , you already have a list, in my case I do not have a list, but a string which has comma delimited values. I need to extract each value and convert them to list of values, so that then i could then loop over them.

                 

                I tried a few functions in XSLT like oraext:create-nodeset-from-delimited-string but no luck.

                I have the XSD of the List into which i would like to copy the extracted values.

                 

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

                <schema attributeFormDefault="unqualified" elementFormDefault="qualified"

                        targetNamespace="http://xmlns.oracle.com/A_OS46TCO_01/Project4/BPELProcess1"

                        xmlns="http://www.w3.org/2001/XMLSchema">

                  <element name="ApproverList">

                    <complexType>

                      <sequence>

                        <element name="approver" type="string" maxOccurs="unbounded"/>

                   

                      </sequence>

                    </complexType>

                  </element>

                </schema>

                 

                I then tried to have a XSLT like

                 

                <xsl:variable name="approvers" select="/ns0:iprocess/ns0:inputList"/>

                      <xsl:variable name="pos" select='oraext:create-nodeset-from-delimited-string(tns:approver,$approvers,",")'></xsl:variable>

                      <xsl:for-each select="$pos">

                        <xsl:variable name="counter" select="position()"/>

                        <tns:approver>

                          <xsl:value-of select="$pos[$counter]"/>

                        </tns:approver>

                      </xsl:for-each>

                 

                This function oraext:create-nodeset-from-delimited-string seems to work on SOA - BPEL with Copylist - copy rule in the Assign Operation . Any idea on how to acheive the same is highly appreciated.

                 

                Thanks in Advance

                • 5. Re: Extract delimited text in Oracle BPM
                  Martien van den Akker

                  Oh, but then you have switched your source and target samples in your original question! That's how I interpretted it.

                   

                  In that case, you need to understand that XSLT is actually a functional programming language, which means that variables in XSLT are immutable.

                  You can solve this by using recursion. See for intance https://blog.darwin-it.nl/2010/08/index-of-replace-and-key-value-parsing.html especially the replace template. I think you need a template like:

                   

                  <xsl:template name="parseDelimitedString">

                    <xsl:param "delimitedStr"/>

                    <!-- https://www.w3schools.com/xml/xsl_functions.asp

                    <xsl:variable name="firstItem" select="substring-before($delimitedStr, ',')" />

                    <xsl:variable name="restDelimitedStr" select="substring-after($delimitedStr, ',')" />

                    <tns:approver>

                      <xsl:value-of select="$firstItem"/>

                    </tns:approver>

                    <xsl:call-template name="parseDelimitedString">

                      <xsl:with-param name="delimitedStr" select="$restDelimitedStr"/>

                    </xsl:call-template>

                  </xsl:template>

                  That you can call with:

                    <xsl:call-template name="parseDelimitedString">

                      <xsl:with-param name="delimitedStr" select="select="/ns0:iprocess/ns0:inputList"/>

                    </xsl:call-template>

                   

                  (Typed by heart, not tested)

                   

                  Regards,

                  Martien

                  1 person found this helpful
                  • 6. Re: Extract delimited text in Oracle BPM
                    Robinson J

                    Hi,

                    Thanks a lot for the help, I just had to add the exit condition for the recursion and then could achieve my requirement.

                      <xsl:template name="parseDelimitedString">

                            <xsl:param name="delimitedStr"/>

                            <!-- https://www.w3schools.com/xml/xsl_functions.asp -->

                            <xsl:variable name="firstItem" select="substring-before($delimitedStr, ',')"/>

                            <xsl:variable name="restDelimitedStr" select="substring-after($delimitedStr, ',')"/>

                            <tns:approvers>

                                <xsl:value-of select="$firstItem"/>

                            </tns:approvers>

                            <xsl:choose>

                            <xsl:when test="contains($restDelimitedStr, ',')">

                                <xsl:call-template name="parseDelimitedString">

                                    <xsl:with-param name="delimitedStr" select="$restDelimitedStr"/>

                                </xsl:call-template>

                            </xsl:when>         

                              <xsl:otherwise>

                                <tns:approvers>

                                  <xsl:value-of select="$restDelimitedStr"/>

                                </tns:approvers>

                              </xsl:otherwise>

                            </xsl:choose>

                           

                        </xsl:template>

                    • 7. Re: Extract delimited text in Oracle BPM
                      Martien van den Akker

                      Yes indeed: forgot that: Recursion => always add an end condition!


                      Nice that it works.

                       

                      Regards,
                      Martien