Custom Web Publishing Guide

Table Of Contents
Appendix C
|
Converting CDML solutions to FileMaker XSLT 125
</form>
The problem is that JavaScript is used to make sure that the user submits a value in the Account Number
field:
<P>
<CENTER>
<A HREF="javascript:document.checkoutform.elements[3].value == '' ?
alert('You must fill out the \'Account number\' field!') : document.checkoutform.submit()">
<IMG SRC="images/continue1.gif" NAME="cont" ALT="Continue"></A>
</CENTER>
</P>
After conversion of this example, there are fewer elements in the checkoutform because the –format tag
has been removed. To fix this example, you must manually change the JavaScript to check
document.checkoutform.elements[2] rather than document.checkoutform.elements[3].
1 The expression evaluation logic in CDML is different from the logic in XSLT. For example, the
following CDML expression outputs “userchoice less than 1” if userchoice is empty:
[fmp-if: currentcookie:userchoice .lt. 1 ]
userchoice less than 1
[fmp-else]
userchoice not less than 1
[/fmp-if]
In XSLT, the same converted expression outputs “userchoice not less than 1” if userchoice is empty:
<xsl:choose>
<xsl:when test="fmxslt:get_cookie('userchoice') &lt; '1'">
userchoice less than 1
</xsl:when><xsl:otherwise>
userchoice not less than 1
</xsl:otherwise>
</xsl:choose>
The reason for the difference is that the CDML expression performs a numeric comparison, but the
XSLT expression performs a string comparison. To return the same results in XSLT as the original
CDML expression, change the XSLT statements to account for the empty string. For example:
<xsl:variable name="userchoice" select="fmxslt:get_cookie('userchoice')"/>
<xsl:choose>
<xsl:when test="string-length($userchoice) = 0 or $userchoice &lt; '1'">
userchoice less than 1
</xsl:when><xsl:otherwise>
userchoice not less than 1
</xsl:otherwise>
</xsl:choose>