Subject: RE: [xsl] the fastest way to test if variable is empty From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 8 Dec 2004 16:21:00 -0000 |
> 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. Michael Kay http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] the fastest way to test if va, Dusan Zatkovsky | Thread | RE: [xsl] the fastest way to test i, Wendell Piez |
Re: [xsl] Defining a key on a RTF i, Mukul Gandhi | Date | Re: [xsl] the fastest way to test i, Wendell Piez |
Month |