[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xsl:if test = empty string, returns true

Subject: Re: xsl:if test = empty string, returns true
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 15 May 2012 13:26:07 -0400
Re:  xsl:if test = empty string
At 2012-05-15 16:02 +0200, Jorge wrote:
Thank you all so much for all the rather granular explanations.

One thing I tried unsuccessfully is finding a way to unequivocally see what was coming out of the function, and what xsl:if was testing. Up until know I have only played with XSLT using a general-purpose text editor and running Saxon a zillion times.

When I started guessing that I was not quite understanding what exactly the function was returning, I tried to find a visual debugger that could describe it to me. I tried Oxygen Developer's demo, but could not find a way to do that (i.e. showing me what exactly xsl:if was testing).

With a slight change to your code, you can use oXygen to tell you. And had I used that, I would have caught my egregious error that, thankfully, Michael was kind enough to point out.

Any heads up on how or with what tool I could have noticed I was getting a node and not a string (besides learning XSLT properly)? I use Mac OS X 10.7 so I am limited by what works on this platform.

I modified your code as follows:

<xsl:template match="/" name="main" exclude-result-prefixes="me">
<xsl:variable name="x" select="me:metadata('testkey')"/>
<xsl:when test="$x">
testkey = "<xsl:value-of select="me:metadata('testkey')"/>"
testkey's length = <xsl:value-of select="string-length(me:metadata('testkey'))"/>
"testkey" is empty or does not exist.

And then using the debugger, when I walk through to the <xsl:choose>, the oXygen Variables window shows that $x contains a text node. When I add my suggested as constraint to the function, the Variables window shows that $x contains a string.

I hope this helps. And thanks, again, as always, to Michael.

. . . . . . . . . . Ken

Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.