This transformation finds if an ascii character is in the (inclusive) range of any two ascii characters:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:variable name="vAscii"> !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:variable>
<xsl:template match="/*">
<xsl:call-template name="isInRange">
<xsl:with-param name="pChar" select="text"/>
<xsl:with-param name="pStarting" select="range/from"/>
<xsl:with-param name="pEnding" select="range/to"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="isInRange">
<xsl:param name="pChar"/>
<xsl:param name="pStarting"/>
<xsl:param name="pEnding"/>
<xsl:value-of select=
"contains($vAscii, $pChar[1])
and
string-length(substring-before($vAscii, $pChar[1]))
>=
string-length(substring-before($vAscii, $pStarting))
and
string-length(substring-before($vAscii, $pEnding))
>=
string-length(substring-before($vAscii, $pChar[1]))
"/>
</xsl:template>
</xsl:stylesheet>
when applied on the following XML document (that contains exactly the provided XML fragment):
<t>
<text>H</text>
<range>
<from> </from>
<to>z</to>
</range>
</t>
produces the wanted result:
true
When applied on this XML document:
<t>
<text>H</text>
<range>
<from>A</from>
<to>G</to>
</range>
</t>
again the correct result is produced:
false