|
next
|
 Subject: Re: Parser returns incorrect values for contains Author: Minollo I. Date: 30 Aug 2001 11:05 PM
|
Adam,
sorry for the delay in answering your message; I just wanted to make a few
additional experiments and to re-read the XSLT specs before answering.
I believe Stylus Studio is doing the right thing.
(Please I will avoid using '<', '>' and '&' because they confuse the way
the response is posted on the forum; I'm using '{', '}' and '%'...)
The problem in your stylesheet is the way you have defined $ta, $lf and
$cr; in XSLT whitespaces are supposed to be ignored (a whitespace character
is #x20, #x9, #xD or #xA; further details at http://www.w3.org/TR/xslt#strip).
That means that the result of...
{xsl:variable name="ta"}%#9;{/xsl:variable}
....is an empty variable $ta... At that point, when you do
contains($content, $ta) the result is always true because $ta is empty, and
contains($whatever, "") is always true.
You can easily duplicate this behavior in both MSXML3 and Xalan; I wonder
how MSXML3 could confirm that your stylesheet is correct.
Replicating the problem is very simple:
{xsl:variable name="ta"}%#9;{/xsl:variable}
{xsl:variable name="aTest" select="contains('peppo',$ta)"/}
{xsl:if test="$aTest"}contains succeeded{/xsl:if}
{xsl:variable name="cTest" select="string-length($ta)"/}
{xsl:value-of select="$cTest"/}
Stylus Studio, MSXML3 and Xalan all return me:
contains succeeded
0
....confirming what I wrote above.
To do what you are trying to do, you should use a CDATA section:
{xsl:variable name="ta"}{![CDATA[%#9;]]}{/xsl:variable}
That way, the processors will return just:
1
....confirming that the tab character has not been found, and that $ta is
not empty this time.
Hope this helps,
Minollo
|
|
|