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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
- Stylus Studio Technical Forum (14621)
-> - Stylus Studio - Registrar en o... (1)
-> + Stylus Studio - Registrar en o... (2)
-> + Can a pipeline send a file by ... (2)
-> + After Updateing WIN10 to WIN11... (12)
-> + Where do I add the custom java... (3)
-> + Where is the Diagram tab? (5)
-> + Applying XSLT to Word DOCX/XML (2)
-> - CSV conversion via ConvertToXM... (1)
-> + Text symbols in SS not same as... (4)
-> + Exposing xquery as webservice ... (6)
-> + Syntax Identifier (2)
-> + Saving a Converted XML as an X... (5)
-> + Output document cannot be pars... (4)
-> - Archiving output from conversi... (1)
-> + EDIFACT guideline from Stylus ... (3)
-> + CSV file putting all the data ... (5)
-> + Can't install Home version 64b... (5)
-> + presale - Can I covers this sc... (5)
-> + Problem with UNB (5)
-> + Splitting EDIFACT files pipeli... (4)
-- [1-20] [21-40] [41-60] Next
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
+ XQuery Help and Discussion (2016)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.