This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: String test pro's /con's
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Mon, 24 Jun 2002 20:30:35 +0100
- Subject: RE: [xsl] String test pro's /con's
- Reply-to: xsl-list at lists dot mulberrytech dot com
> To test if an element contains data (any string) what is the
> difference/benefits/cons?? to either of the following:
>
> <xsl:if test="string-length(./myelement)> 0 )
>
> or
>
> <xsl:if test="not(./myelement='')">
>
Use the second. string-length() can be an expensive operation because of
the need to scan the string looking for Unicode surrogate pairs. But of
course, performance questions are always processor-dependent. Saxon
optimizes the first expression to avoid scanning the string; other
processors may have ways of storing strings that make it faster to look
for surrogate pairs.
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list