Assuming you're limited to XSLT 1.0, you could try:
<xsl:variable name="ascii">!"#$%&'()*+,-./0123456789:;=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:variable>
<xsl:variable name="spaces" select="' '" />
<xsl:template match="input">
<xsl:copy>
<xsl:value-of select="translate(., translate(., $ascii, ''), $spaces)"/>
</xsl:copy>
</xsl:template>
This is a bit hacked: it will work as long as $spacesthere are enough spaces in the variable to accommodate all the non-ascii characters found in the input.
If you do not want to rely on such an assumption, you will have to use a recursive template to replace them one by one:
<xsl:template match="input">
<xsl:copy>
<xsl:call-template name="replace-non-ascii">
<xsl:with-param name="text" select="."/>
</xsl:call-template>
</xsl:copy>
</xsl:template>
<xsl:template name="replace-non-ascii">
<xsl:param name="text"/>
<xsl:variable name="ascii"> !"#$%&'()*+,-./0123456789:;=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:variable>
<xsl:variable name="non-ascii" select="translate($text, $ascii, '')" />
<xsl:choose>
<xsl:when test="$non-ascii">
<xsl:variable name="char" select="substring($non-ascii, 1, 1)" />
<xsl:call-template name="replace-non-ascii">
<xsl:with-param name="text" select="translate($text, $char, ' ')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
source
share