[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Testing the Last Character of a String

Subject: RE: Testing the Last Character of a String
From: Michele R Combs <mrrothen@xxxxxxx>
Date: Thu, 1 Aug 2013 15:14:26 +0000
RE:  Testing the Last Character of a String
Since the test starts with "archdesc/..." I assume it's getting run while at
the root level (ead), is that correct?   If so, then I'm pretty sure you just
need single quotes around the period.  Also you don't need the 1.

<xsl:when test="substring(archdesc/did/unittitle/text(),
string-length(archdesc/did/unittitle))='.'">


If you're going to be doing other things with this unittitle, such as
outputting it or concatenating it, you might save some space by sticking it in
a variable:

<xsl:variable name="collectionTitle" select="
archdesc/did/unittitle/text()"/>
...
<xsl:when test="substring($collectionTitle,
string-length($collectionTitle))='.'">
...
<xsl:value-of select="$collectionTitle"/>

Michele

-----Original Message-----
From: Nathan Tallman [mailto:ntallman@xxxxxxxxx]
Sent: Thursday, August 01, 2013 10:56 AM
To: xsl-list
Subject:  Testing the Last Character of a String

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>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.