[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
At 2012-05-15 16:02 +0200, Jorge wrote:
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.
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
Re: [xsl] xsl:if test = empty string, returns true
Subject: Re: [xsl] xsl:if test = empty string, returns true From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 15 May 2012 13:26:07 -0400 |
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: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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsl:if test = empty strin, Jorge | Thread | [xsl] XQuery and XForms courses in , C. M. Sperberg-McQue |
Re: [xsl] xsl:if test = empty strin, Jorge | Date | [xsl] Creating multiple xmls using , Siddhi Thakkar |
Month |