<func:function name="mime:split64-dac">
    <xsl:param name="str"/>

    <xsl:variable name="strlen" select="string-length($str)"/>

    <xsl:choose>
      <xsl:when test="$strlen &lt;= 76">
        <func:result select="concat(substring($str,1,76),$CRLF)"/>
      </xsl:when>

      <xsl:otherwise>
        <xsl:variable name="mid" 
          select="76 * ceiling($strlen div 152)"/>

        <func:result select="concat(
                               mime:split64-dac(substring($str, 1, $mid)),
                               mime:split64-dac(substring($str, $mid +1))
                             )"
        />
      </xsl:otherwise>
    </xsl:choose>
  </func:function>