xsl-list
[Top] [All Lists]

[xsl] Testing the Last Character of a String

2013-08-01 09:56:28
I'd like to test the last character in a node text-string. If it's a
period, then insert the value and a space. If it's not a period, then
insert the value, a period., and a space. I think I've gotten most of
the code right, but don't have it quite right, as it's not working. Any tips?

Thanks,
Nathan

<xsl:choose>
    <xsl:when test="substring(archdesc/did/unittitle/text(),
string-length(archdesc/did/unittitle), 1)=.">
        <xsl:value-of select="normalize-space(archdesc/did/unittitle)"/>
        <xsl:text>&#160;</xsl:text>
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="normalize-space(archdesc/did/unittitle)"/>
        <xsl:text>.&#160;</xsl:text>
    </xsl:otherwise>
</xsl:choose>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>