Something like this:
<xsl:choose>
<xsl:when test="string-length(first) + string-length(last) < 50">
<xsl:value-of select="concat(first, ' ', last)"/>
</
<xsl:otherwise>
<xsl:message>Name truncated!</xsl:message>
<xsl:value-of select="concat(substring(first, 1, 1), ' ', last)"/>
</
</
Michael Kay
Saxonica
On 29/09/2010 10:42 AM, sudheshna iyer wrote:
I have below java code. I need to convert to xslt. How do i achieve this?
Requirement:
If (first name + last name) exceeds 50 char, then use (first char of first name
+ complete last name) and create ErrorMessage indicating that name got
truncated.
String strFirstName = "";
String strLastName = "";
StringBuffer ErrorMessage = new StringBuffer("");
StringBuffer name = new StringBuffer(strFirstName);
name.append(" " + strLastName);
if(name.length()> NAME_LEN){
//Build the name
name.delete(0, name.length());
name.append(strFirstName.substring(0,1) + " " + strLastName.substring(0));
//Name = name.substring(0,NAME_LEN);
if(name.length()> NAME_LEN)
Name = name.substring(0,NAME_LEN);
else
Name = name.substring(0,name.length());
ErrorMessage = ErrorMessage.append("Name= " + strFirstName + " " + strLastName +
",");
} else{
Name = name.toString();
}
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--