Tuesday, June 11, 2013

XSLT Template to split a string received in node and create repeating node on destination end

Use the following XSLT Call Template in scripting functoid to split a ; (semi-colon) separated string and create a repeating structure on the destination end using the values retrieved from split

<xsl:template match="ns0:QI_Notifications/ns0:QICountry__c/text()" name="split" xmlns:ns0="http://soap.sforce.com/2005/09/outbound" xmlns:ns1="http://webservice.mks.com/2009/Integrity/schema">
<xsl:param name="pText" select="."/>
<xsl:if test="string-length($pText)">
<ns1:value>
<xsl:value-of select="substring-before(concat($pText,';'),';')"/>
</ns1:value>
<xsl:call-template name="split">
<xsl:with-param name="pText" select="substring-after($pText, ';')"/>
</xsl:call-template>
</xsl:if>
</xsl:template>


**template matches the node from source which contains semi-colon separated string