How to check if String is Null or Empty in XSL

To check if String is Null or Empty in XSL you can use the following snippet.

Sample XSL

<xsl:choose>
    <xsl:when test="fieldToTest != ''">
        <xsl:value-of select="Field1Value" />
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="Field2Value" />
    </xsl:otherwise>
</xsl:choose>

Please rate this snippet

How to empty an array in Javascript

To empty an array in Javascript you can use the following methods.

Sample Javascript

myArray = [];

This code will set the variable A to a new empty array (take care if you have references to the “old” array).

or

myArray.length = 0

This will clear the existing array by setting its length to 0.

or

myArray.splice(0,myArray.length)

Working, but not recommended for this task. see Array.prototype.splice()

or

while(myArray.length > 0) {
    myArray.pop();
}

Fastest solution, without breaking references.

Please rate this snippet