Thursday, May 1, 2014

Split a String in XSL


How to Split a String using/in  XSL.

This example will show how to split a string into a node set using delimiter in XSL.

Example:

Input:  

<Test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/SplitString file:/D:/JDevMyWork/BPMApplication/SplitString/xsd/SplitString.xsd" xmlns="http://xmlns.oracle.com/SplitString">
   <CheckList>Bank statement, License, ID proof</CheckList>
 </Test>

Output:

<ns0:Test xmlns:ns0="http://xmlns.oracle.com/SplitString" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/SplitString file:/D:/JDevMyWork/BPMApplication/SplitString/xsd/SplitString.xsd">
   <ns0:CheckList>Bank statment</ns0:CheckList>
   <ns0:CheckList>License</ns0:CheckList>
   <ns0:CheckList>ID Proof</ns0:CheckList>
</ns0:Test>

In this example I have used same xsd for both input and output. You can use different type of variables too. As you can see based on "," as delimiter the input string has been divided into a node-set.

You will need to use Recursive templates to achieve this as shown below.




Complete XSL:

 <xsl:template match="/">
        <ns0:Test>
            <xsl:call-template name="tokenize">
                <xsl:with-param name="text" select="/ns0:Test/ns0:CheckList"/>
            </xsl:call-template>
        </ns0:Test>
    </xsl:template>
    <xsl:template match="text/text()" name="tokenize">
        <xsl:param name="text" select="$text"/>
        <xsl:param name="separator" select="','"/>
        <xsl:choose>
            <xsl:when test="not(contains($text, $separator))">
                <ns0:CheckList>
                    <xsl:value-of select="normalize-space($text)"/>
               </ns0:CheckList>
            </xsl:when>
            <xsl:otherwise>
                <ns0:CheckList>
                    <xsl:value-of select="normalize-space(substring-before($text, $separator))"/>
                </ns0:CheckList>
                <xsl:call-template name="tokenize">
                    <xsl:with-param name="text"
                                    select="substring-after($text, $separator)"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>

Shoot a comment, if you need any help.

Monday, April 28, 2014

Get List of Users in Application Role of BPM.


Get list of users assigned to a Application Role in BPM.

How to get list of users assigned to a Application Role?

you can use function  ids:getUsersInAppRole() to get the list of users for an application Role.
Check my previous post on how to use Identity functions.
Here is the link.

http://kvkvinod.blogspot.in/2014/04/bpmsoa-identity-functions-ex.html

 

There are different options for this function. You can get list of users for a BPMProcess role or BPMComposer role or even for soa-infra. You can see the same in the description.

Similar to my earlier post, you need to create a variable based on "Users" element from the schema and use "Copy List" to assign the output of the function to the  variable as shown in the below picture.

 

Leave a comment if you need any help with this.