XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Adam Van den HovenSubject: Parser returns incorrect values for contains
Author: Adam Van den Hoven
Date: 30 Aug 2001 08:28 PM
Hi, 

I've been using cooktop for a while but I decided to give Excelon a shot since I have a copy anyways. 

I have the following recursive template that takes a string passed to it and javascript escapes important characters (tabs, newlines etc). The templates looks like (I took out the tabbing):



	



"
'
\









\t








\n








\r








\"








\'








\\











Now I added $aTest $bTest $cTest to prove to myself that I'm not going insane. I have encountered a situation where $aTest is true and $cTest is 0. That that means is that contains($content, '	') is returning true even if there is no tab in there. It gets worse because I end up in an infinite loop since i pass the substring before the tab recursively to the template (convert all the tabs) which contains nothing and the contains is still returning true. 

I've confirmed that my function works fine with MSXML3.

Adam

Postnext
Minollo I.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

Posttop
Darren HaydukSubject: Re: Parser returns incorrect values for contains
Author: Darren Hayduk
Date: 31 Aug 2001 01:36 PM
Is the CDATA section still in XMLSchemas (I thought it was a DTD-only thing...)

I've used {xsl:text} for this purpose:

{xsl:variable name="ta"}
{xsl:text}%#9;{/xsl:text}
{/xsl:variable}

Darren

On 8/30/01 11:05:20 PM, Carlo Innocenti wrote:

> 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.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.