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 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Neal WaltersSubject: Testing for empty string - something obvious not working
Author: Neal Walters
Date: 03 May 2006 06:01 PM
Originally Posted: 03 May 2006 05:39 PM
I think I'm going crazy here. I'm in a called template. I'm using debugger, and $updatedPhone is supposed blank and seems to be blank, and even shows a string-length of zero. However using F11 in the debugger, it passes right over a test of ($updatedPhone = ''). <br> I don't understand why this is not true. DEBUG $updatedPhone="<xsl:value-of select="string-length($updatedPhone)"/>" <xsl:if test="$updatedPhone = ''"> <!-- this never gets executed --> <xsl:value-of select="$typePhone"/> phn deleted </xsl:if> In my craziness - I put a not around the != and the test is now true. <xsl:if test="not($updatedPhone != '')"> <xsl:value-of select="$typePhone"/> phn deleted </xsl:if> Can anyone shed some light on this? Thanks again, Neal Walters http://Biztalk-Training.com

Postnext
Ivan PedruzziSubject: Testing for empty string - something obvious not working
Author: Ivan Pedruzzi
Date: 04 May 2006 11:52 AM

Which XSLT processor have you congigured in the scenarion?

We don't see this happening
Could you please send us a full example?

Ivan Pedruzzi
Stylus Studio Team

Postnext
Neal WaltersSubject: Testing for empty string - something obvious not working
Author: Neal Walters
Date: 04 May 2006 06:55 PM
Originally Posted: 04 May 2006 06:02 PM
I probably should have posted this under XSLT - it's related to the DeepDiff example you gave me - which is working great by the way. <br> <br> I'm getting problem with Net 1.0 processor (and built-in). This is the test that's causing problem: <xsl:if test="$updatedPhone = ''"> The value seems to be blank based on the debugger and the "debug:" statement I added. We also did a string-length and it was 0. Thanks a lot for your help so many times! Neal


DocumentReproductIfTestProblem.xslt
Reproduce Problem XSLT

DocumentReproductIfTestProblemData.xml
Reproduce Problem XML

Postnext
Neal WaltersSubject: Testing for empty string - something obvious not working
Author: Neal Walters
Date: 04 May 2006 06:27 PM
What did I do to mess up my messages - i.e. formatting?

Neal

Postnext
Ivan PedruzziSubject: Testing for empty string - something obvious not working
Author: Ivan Pedruzzi
Date: 04 May 2006 06:30 PM
Hi Neal,

Most likely the processor evaluates $updatedPhone to NaN so the comparison fails.

That's easy to fix, change the expression to force the type coercion

<xsl:if test="string($updatedPhone) = ''">::<xsl:value-of select="$typePhone"/> phn deleted</xsl:if>

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
Neal WaltersSubject: Testing for empty string - something obvious not working
Author: Neal Walters
Date: 04 May 2006 06:55 PM
Originally Posted: 04 May 2006 06:51 PM
You're right on again. <br> <br> But how could a string be NaN (not-a-number)? Is NaN the way XSLT expresses Null? <br> Why doesn't the debugger show NaN? <br> Is there somewhere I can go to read about NaN vs Null vs empty-string in XSLT? <br> <br> Thanks,<br> Neal <br> P.S. I think my messages get messed up when I click edit, then change them.

Posttop
Ivan PedruzziSubject: Testing for empty string - something obvious not working
Author: Ivan Pedruzzi
Date: 05 May 2006 12:18 AM

I used the term NaN improperly.

When the processor compares two expressions needs to convert both terms to the same type before proceed.

In this case one of the term is nothing so there is no type then processor gives up and returns false.

Using a type contructor like string() forces the processor to build a string then inevitably is an empty string.

I hope I didn't bore you to death :)

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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.