bsh % String s1 = "1234";
bsh % String s2 = "A1234";
bsh % print(Character.isLetter(s1.charAt(0)));
false
bsh % print(Character.isLetter(s2.charAt(0)));
true
This is of course Unicode safe. With XSL though I could not find a similar feature but for my purposes it was sufficient to reverse the check and see if I had a Latin number first. Here is how:
<xsl:template match="/person/personnumber">
<reference>
<xsl:variable name="num">
<xsl:value-of select="."/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains('0123456789', substring($num, 1, 1))">
<xsl:variable name="snum">
<xsl:call-template name="removeLeadingZeros">
<xsl:with-param name="originalString" select="$num"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="concat('PE', $snum)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</reference>
</xsl:template>
No comments:
Post a Comment