Forum Stats

  • 3,760,116 Users
  • 2,251,647 Discussions
  • 7,870,985 Comments

Discussions

Extract delimited text in Oracle BPM

Robinson J
Robinson J Member Posts: 7

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

Answers

  • Martien van den Akker
    Martien van den Akker Member Posts: 2,776 Bronze Crown
    edited Oct 16, 2018 3:37AM

    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

  • d465f42a-f285-4724-b7d9-9bbf75085cf4
    edited Oct 16, 2018 3:57AM

    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.

  • Martien van den Akker
    Martien van den Akker Member Posts: 2,776 Bronze Crown
    edited Oct 16, 2018 4:49AM

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

    Regards,
    Martien

  • Robinson J
    Robinson J Member Posts: 7
    edited Oct 16, 2018 11:37AM

    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

  • Martien van den Akker
    Martien van den Akker Member Posts: 2,776 Bronze Crown
    edited Oct 17, 2018 3:21AM

    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

    Robinson J
  • Robinson J
    Robinson J Member Posts: 7
    edited Oct 17, 2018 8:57AM

    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>

  • Martien van den Akker
    Martien van den Akker Member Posts: 2,776 Bronze Crown
    edited Oct 17, 2018 9:51AM

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


    Nice that it works.

    Regards,
    Martien