Usecase: Here, we will demonstrate how we can use multiple nested loops one level to fetch skill id based on qualification code for each HCM person.
Bascially person data has qualication codes and we have skill ids, qualifications codes in skill data, and we need to populate a target payload incorporating person details plus skill id based on person qualification code. Thats why need two loops - one outer represents person and one inner represents skill and for each person , we are matching qualification codes for both and fetching skill id and more over, each person can have multiple skills for a qualification codes.
Xslt code used:
<xsl:template match="/" xmlns:id="id_11">
<nstrgmpr:Write xmlns:id="id_12">
<ns36:Recordset xmlns:id="id_54">
<xsl:for-each select="$Stage_ReadPersonRecords/nsmpr9:ReadResponse/nsmpr9:PersonRecord">
<xsl:variable name="QualificationCode" select="nsmpr9:QUALIFICATION_CODE"/>
<xsl:variable name="PersonNumber" select="nsmpr9:PERSON_NUMBER"/>
<xsl:variable name="ValidTo" select="nsmpr9:VALID_TO"/>
<xsl:variable name="TrainingCompletionDate" select="nsmpr9:TRAINING_COMPLETION_DATE"/>
<xsl:for-each select="$Stage_ReadSkillIdData/nsmpr4:ReadResponse/ns29:Record[ns29:Code=$QualificationCode]">
<ns36:Record xmlns:id="id_55">
<ns36:Responsible xmlns:id="id_58">
<xsl:value-of xmlns:id="id_59" select="$PersonNumber"/>
</ns36:Responsible>
<ns36:Skill xmlns:id="id_56">
<xsl:value-of xmlns:id="id_254" select="ns29:Id"/>
</ns36:Skill>
<ns36:Valid until xmlns:id="id_60">
<xsl:value-of xmlns:id="id_61" select="$ValidTo"/>
</ns36:Valid until>
<ns36:Validity_period xmlns:id="id_62">
<xsl:choose>
<xsl:when test="$ValidTo != """>
<xsl:value-of xmlns:id="id_63" select=""Yes""/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of xmlns:id="id_63" select=""No""/>
</xsl:otherwise>
</xsl:choose>
</ns36:Validity_period>
<ns36:Achievement_Date xmlns:id="id_64">
<xsl:value-of xmlns:id="id_65" select="$TrainingCompletionDate"/>
</ns36:Achievement_Date>
<ns36:Score xmlns:id="id_66">
<xsl:value-of xmlns:id="id_67" select=""Pass""/>
</ns36:Score>
</ns36:Record>
</xsl:for-each>
</xsl:for-each>
</ns36:Recordset>
</nstrgmpr:Write>
</xsl:template>