[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl:if test = empty string, returns true
At 2012-05-15 16:02 +0200, Jorge wrote:
Thank you all so much for all the rather granular explanations. 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:choose> <xsl:when test="$x"> testkey = "<xsl:value-of select="me:metadata('testkey')"/>" testkey's length = <xsl:value-of select="string-length(me:metadata('testkey'))"/> </xsl:when> <xsl:otherwise> "testkey" is empty or does not exist. </xsl:otherwise> </xsl:choose> </xsl:template> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|