Trouble with XSL true/false
This is an open discussion with 12 replies, filed under XSLT.
Search
Weirdly, $enable-sharing
= 'yes'
but boolean($enable-sharing = 'yes')
= false()
This is really confusing me now.
This is wrong isn't it??
$has-video is a boolean value, and equates to 'true`
Which field in Symphony generates a boolean? A checkbox for example stores 'yes' and 'no', from my experience.
Did you already try something like this?
test="($has-video = 'yes') and ($enabled sharing = 'yes')"
Just testing this some more...
<xsl:comment> <xsl:text>n</xsl:text> <xsl:value-of select="$enable-sharing"/><xsl:text>n</xsl:text> <xsl:value-of select="boolean($enable-sharing = 'yes')"/><xsl:text>n</xsl:text> <xsl:value-of select="$sharethis"/><xsl:text>n</xsl:text> <xsl:value-of select="boolean($sharethis = 'no')"/><xsl:text>n</xsl:text> </xsl:comment>
$enable-sharing
is set to yes
, it's a parameter that defaults to no
if yes
isn't passed in to the template (which it is being). $sharethis
is a test variable I created that is set to no
. The above comment is output as:
<!-- 'yes' false no true -->
Now I think I can see the problem. 'yes'
still has the delimiters wrapped around it. How is this even possible?? I'm passing it in as a string, so why isn't it being equated that way?
Jens, this is templating stuff, not direct output from Symphony. I am doing logic based on a set of templates that require configuring.
Hm, you can set the value of a variable to 'yes'
with something like
<xsl:variable name="foo">'yes'</xsl:variable>
So I guess you should have a look how the value of $enable-sharing
is set. Can you show the code?
Allright, then I'll shut up as quickly as possible and check back later to see how the real geniuses solved this... ;)
How is this even possible?? I'm passing it in as a string, so why isn't it being equated that way?
How are you setting this value? <xsl:variable name="enable-sharing" select="'yes'"/>
?
Edit; as always I was too slow :(
In the template that this logic is in, it is set as a parameter like so
<xsl:param name="enable-sharing" value="'no'"/>
But this is overridden by calling the template like so
<xsl:apply-templates select="our-work-case-studies/client[@link-handle = $client]/entry" mode="card"> <xsl:with-param name="mode" select="'case-study'"/> <xsl:with-param name="article-classes" select="'case-study'"/> <xsl:with-param name="enable-sharing" select="'yes'"/> </xsl:apply-templates>
As far as I was aware, passing data like this should make a string in the template without the '
around it, but it isn't.
As far as I was aware, passing data like this should make a string in the template without the ' around it, but it isn't.
Well, it should, and on my installations, it does. Can you please show a bit more of the template? To me it seems like the variable is by accident set anywhere else with the quotes around them.
Oh. My. God. I'm such an idiot.
For some reason unbeknownst to me, I had set the value of the parameter to 'yes'
as xsl:text
and not via the select
method.
The template is chained you see, the above call calls a card
template, then passes the values along to a panel
template. It's in that passing I had messed up.
Thanks for your input guys, my bad all along. Syntax error.
Oh. My. God. I'm such an idiot.
Phew. Glad you got it sorted!
Oh. My. God. I'm such an idiot.
Aha!
LOL.
Create an account or sign in to comment.
So, I don't get this at all...
Consider the following:
$has-video
is a boolean value, and equates to 'true`$enable-sharing
is a string and it's value isyes
Can someone explain to me why the following is so:
The above test equates to
false
. As does...
Are double positives turned into a negative or something? If so how would I check if both values are true, then continue??