Dusan,
Joining in again....
At 11:21 AM 12/8/2004, Mike wrote:
>
> Can anybody tell me the fastest way, how to test, if variable
> contains some
> text or number?
>
> For now, i am using test "string-length($variable)=0", but
> seems not to be the fastest.
What makes you think it isn't the fastest?
Speed of different operations will vary between processors, but I would be
very surprised if this operation is the cause of your performance
difficulties.
I would recommend writing it as $variable='' since a non-optimizing
processor will otherwise count all the characters in the string, which can
take a while if the string is long and a variable-length character
representation is used (e.g. UTF-8 or UTF-16).
> Somebody tells me to use test "$variable", but with my
> XalanC, it seems to be true everytime.
That makes me suspect you have declared the variable as
<xsl:variable name="x">
...
</xsl:variable>
which means that (contrary to what you said) its value isn't a string or a
number, but a result-tree-fragment, which is likely to be much less
efficient.
I left out the possibility of $variable being an RTF; but problems with
testing RTFs are similar to those testing node-sets, and the string() and
normalize-space() tests work on them too.
But I should also add that the normalize-space() approach will *not* be
fast, since it requires processing the string to collapse white space,
which is not unlike counting the characters....
So listen to Mike (I know you do :-).
Cheers,
Wendell
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
--~------------------------------------------------------------------
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>
--~--