<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version = "1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:func="http://exslt.org/functions"
    extension-element-prefixes="func">
    
    <xsl:template match="site">
        <xsl:value-of select="func:a(1)" />
    </xsl:template>

    <func:function name="func:a">
        <xsl:param name="depth">0</xsl:param>
        <xsl:param name="unused" select="func:string-clear( 'dd.mm.YYYY' )" />

        <func:result>
            <xsl:choose>
                <xsl:when test="$depth &gt; 10">
                    <xsl:value-of select="$depth + 1" />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="func:a($depth + 1)" />
                </xsl:otherwise>
            </xsl:choose>
        </func:result>
    </func:function>

	<func:function name="func:string-clear">
		<xsl:param name="string" />
		<xsl:param name="pattern">_</xsl:param>
		<xsl:param name="chars">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789</xsl:param>

		<func:result select="func:string-clear-char( $string, $pattern, $chars )" />
	</func:function>

	<func:function name="func:string-clear-char">
		<xsl:param name="string" />
		<xsl:param name="pattern" />
		<xsl:param name="chars" />
		<xsl:param name="position">1</xsl:param>

		<func:result>
			<xsl:choose>
				<xsl:when test="$position &gt; string-length( $string )">
					<xsl:copy-of select="$string" />
				</xsl:when>

				<xsl:otherwise>
					<xsl:variable name="_string">
						<xsl:choose>
							<xsl:when test="contains( $chars, substring( $string, $position, 1 ) )">
								<xsl:copy-of select="$string" />
							</xsl:when>

							<xsl:otherwise>
								<xsl:copy-of select="concat( substring( $string, 0, $position ), $pattern, substring( $string, $position + 1 ) )" />
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>

					<xsl:copy-of select="func:string-clear-char( $_string, $pattern, $chars, $position + 1 )" />
				</xsl:otherwise>
			</xsl:choose>
		</func:result>
	</func:function>
</xsl:stylesheet>