I have a function as follows
Code:
<xsl:function name="fns:getClassft" as="xs:string">
<xsl:param name="root" as="xs:string"/>
<xsl:choose>
<xsl:when test="$root = 'F'">F</xsl:when>
<xsl:when test="$root = 'H'">H</xsl:when>
<xsl:when test="$root = 'O'">I</xsl:when>
<xsl:when test="$root = 'P'">C</xsl:when>
<xsl:when test="$root = 'R'">R</xsl:when>
<xsl:when test="$root = 'S'">S</xsl:when>
<xsl:when test="$root = 'U'">U</xsl:when>
<xsl:otherwise>E</xsl:otherwise>
</xsl:choose>
</xsl:function>
This is called using the following;
Code:
<xsl:value-of select="fns:getClassft($simple/proposerclassft)"/>
when in the input xml this field appears twice, the function returns a null and causes the entire transform to fall over.
Code:
<proposerclassft>R</proposerclassft>
<proposerclassft>R</proposerclassft>
If i remove one of the above, it works fine.
Any idea why this is causing the function/transform to stop dead when called?
is there some extra code needed to handle this null and cause it to output the otherwise when a null occurs?
Usually there would not ever be a duplicated field in the XML but i need the transform to be defensively built to not fall over if one were to occur.
Below is a snipper of the transform and the end section (where it fall over) of the xml produced.
Transform;
Code:
<Occupation>
<Occupation_Code Val='<xsl:value-of select="$simple/proposerocccodeft" />' />
<Occupation_EmploymentType Val='<xsl:value-of select="fns:getClassft($simple/proposerclassft)"/>' />
<Occupation_EmployersBusiness Val='<xsl:value-of select="$simple/proposerempcodeft" />' />
<Occupation_FullTimeEmploymentInd Val='Y' />
</Occupation>
Output XML;
Code:
<Occupation>
<Occupation_Code Val='R09' />
<Occupation_EmploymentType Val='</xrt:RequestXML></ns:messageIn></ns:ProcessTran></soapenv:Body></soapenv:Envelope>