Tuesday, August 7, 2012

Debugging XSLT script

To know what is the output of a XSLT function or variable we can simply use <xsl:message> to do a print statement in the xslt transfromation script.

Eg:  In the following template when we do the substring operation we might need to know, what is the input we are getting in our template.

<xsl:template name="FindPhoneNum">
    <xsl:param name="DigitsLength" />
    <xsl:param name="PhoneNum" />
    <xsl:message>
        PhoneNum---------:
        <xsl:value-of select="$PhoneNum" />
        DigitsLength---------:
        <xsl:value-of select="$DigitsLength" />
    </xsl:message>   
    <xsl:variable name="number">
        <xsl:value-of select="substring($PhoneNum, $DigitsLength -6, $DigitsLength)" />
    </xsl:variable>
    <xsl:value-of select="$number" />
</xsl:template>
Output will be like;

PhoneNum---------: 18168918984
DigitsLength---------: 11

No comments:

Post a Comment