cjhukill 0 Newbie Poster

I am attempting to add a custom function to my schematron rule stylesheet to aid in looking up values in code tables. I continue to receive an error message: 'XPST0017 XPath syntax at char 0 on line 545 near (...ookupExpression('SEX'): Cannot find a matching 1-argument function named (functions:1.0)BuildLookupExpression())'

At the top of the file, I have the following declarations:

<?xml version="1.0" encoding="UTF-8"?> 
<schema xmlns="http://purl.oclc.org/dsdl/schematron"
    xmlns:sch="http://purl.oclc.org/dsdl/schematron"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
    xmlns:local-fn="functions:1.0"
    xmlns:regexp="http://exslt.org/regular-expressions"
    queryBinding="xslt2"> 

    <sch:ns uri="functions:1.0" prefix="local-fn" />

.
.
.
and the function declaration as:

<!-- *********************************** Functions ***********************  --> 
<!-- special variables for lookup table --> 
<xsl:key name="Code-Lookup" match="CodeTable" use="Code"/> 
<xsl:variable name="codeTables" select="document('LookupCodes.xml')/CodeTable"/> 
<!-- function to return an expression to be evaluated in the rule containing the codes from the given code table --> 
<xsl:function name="local-fn:BuildLookupExpression" as="xs:string"> 
    <xsl:param name="TableName" as="xs:string"/> 
    <xsl:text>(</xsl:text> 
    <xsl:for-each select="key('Code-Lookup', $TableName)/Code"> 
        <xsl:value-of select="."/> 
        <xsl:if test="position() != last()"> 
            <xsl:text>)|(</xsl:text> 
         </xsl:if> 
         <xsl:if test="position() = last()"> 
             <xsl:text>)</xsl:text> 
          </xsl:if> 
      </xsl:for-each> 
  </xsl:function>

.
.
.
in the body, I use the rule:

    <sch:pattern id="SEXValue"> 
        <sch:title>Person Sex</sch:title> 
        <sch:p class="description">
            This field is used to report the gender of the subject.
            See SEX Table: [F, G, M, N, X, Y, Z]
        </sch:p> 

        <let name="SEXExpression" value="local-fn:BuildLookupExpression('SEX')"/> 
        <sch:rule context="nc:PersonSexCode"> 
            <let name="SEXString" value="string(.)"/> 
            <sch:assert test="matches($SEXString, $SEXExpression)"> 
                <sch:value-of select="name(.)" /> must be in the set of: [F, G, M, N, X, Y, Z] 
            </sch:assert> 
         </sch:rule> 
      </sch:pattern>

What am I missing?