Custom Web Publishing with XML and XSLT

Table Of Contents
70 FileMaker Server Custom Web Publishing with XML and XSLT
Comparing strings using Perl 5 regular expressions
You can use the fmxslt:regex_contains() extension function to compare strings using Perl 5 regular
expressions. A regular expression comparison is an advanced type of text matching that enables you to
determine if a string matches a specified pattern. The syntax of this function is:
fmxslt:regex_contains(String input, String pattern)
where input is a string and pattern is a Perl 5 regular expression. For more information on the syntax of Perl 5
regular expressions, see www.perldoc.com. The fmxslt:regex_contains() function returns a boolean value.
This function is useful if you need more advanced string manipulation than is provided by standard XSLT.
For example, you can determine if a field value contains a valid telephone number or email address by
comparing the string against a Perl 5 regular expression.
Here is an example of using this function to determine if a field value contains email addresses that are
constructed correctly:
<xsl:variable name="email" select="'foo@bar.com'"/>
<xsl:if test="fmxslt:regex_contains($email,'^\w+[\w-\.]*\@\w+((-\w+)|(\w*))\.[a-z]{2,3}$')">Valid Email</xsl:if>
If the Web Publishing Engine cannot parse the pattern, the error status is set to error code 10311. See “Error
code numbers for the FileMaker XSLT extension functions” on page 113.
Checking for values in a field formatted as a checkbox
You can use the following extension function to determine whether a particular value in a checkbox value
list is stored in a field in the FileMaker database:
fmxslt:contains_checkbox_value(String valueString, String valueListEntry)
where valuestring is an XPath specifying the field, and valueListEntry is the value you want to check for.
If the specified value is stored in the field, this boolean function returns true(). Otherwise, it returns false().
You can use this function to determine whether to set the checked attribute in an HTML form to display a
checkbox as being selected.
For example, suppose a field in a FileMaker database layout has the following checkbox options:
[ ] Red
[ ] Blue
[ ] Green
[ ] Small
[ ] Medium
[ ] Large
If a user selected Red only, then the field would contain the string “Red”. To determine whether the field
contains “Blue”, you could use the following function call:
fmxslt:contains_checkbox_value(<field value node>,'Blue')
where <field value node> is the XPath to the <data> element for the checkbox field. The function would return
false” in this example.