Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jonas Eriksson 930 posts 1825 karma points
    Feb 18, 2010 @ 14:06
    Jonas Eriksson
    0

    Back to the beginning : OR does not behave

    Hi!

    According to my xslt, false OR false = true ... :-o Scary!

        <xsl:variable name="alreadyRegistredFirst"><xsl:value-of select="boolean(umbraco.library:GetXmlNodeById($calendarid)/descendant::node [data [@alias='Kundnr']=$kundnr])"/></xsl:variable>
    <xsl:variable name="alreadyRegistredSecond"><xsl:value-of select="boolean(umbraco.library:GetXmlNodeById($calendarid)/descendant::node [data [@alias='Personnummer']=$pnumber and data [@alias='Foretag']=$foretag and data [@alias='Namn']=$name])"/></xsl:variable>
    <xsl:variable name="alreadyRegistred"><xsl:value-of select="$alreadyRegistredFirst or $alreadyRegistredSecond"/></xsl:variable>

    (<xsl:value-of select="$alreadyRegistredFirst"/> OR <xsl:value-of select="$alreadyRegistredSecond"/> = <xsl:value-of select="boolean($alreadyRegistred)"/>)

    This expression for $alreadyRegistred actually returns true even though both expressions it tests are false.

    What did I mess up this time?

    Thanks alot for some help here

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Feb 18, 2010 @ 14:11
    Peter Dijksterhuis
    2

    What happens if you try:

    <xsl:value-of select="($alreadyRegistredFirst = true) or ($alreadyRegistredSecond = true)"/></xsl:variable>

    HTH,

    Peter

  • Jonas Eriksson 930 posts 1825 karma points
    Feb 18, 2010 @ 15:29
    Jonas Eriksson
    1

    Hi!

    Thanks Peter, but may I ask, how should that change things to add an extra "= true"?

    Moving in the whole selects inside the variable tag solved my problem, and with a logical reason to it all (I think), phew:

        <xsl:variable name="alreadyRegistredFirst" select="boolean(umbraco.library:GetXmlNodeById($calendarid)/descendant::node [data [@alias='Kundnr']=$kundnr])"/>
       
    <xsl:variable name="alreadyRegistredSecond" select="boolean(umbraco.library:GetXmlNodeById($calendarid)/descendant::node [data [@alias='Personnummer']=$pnumber and data [@alias='Foretag']=$foretag and data [@alias='Namn']=$name])"/>
       
    <xsl:variable name="alreadyRegistred" select="$alreadyRegistredFirst or $alreadyRegistredSecond"/>

    The reason for this might be that the $alreadyRegistredFirst and $alreadyRegistredSecond became string "false" instead of boolean false when the value was outside the variable-tag, right?

    Regards

    Jonas

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Feb 18, 2010 @ 15:42
    Peter Dijksterhuis
    0

    I'm not sure, but I do know that in some languages assigning a variable to true, upon re-using that variable isn't always treated as being boolean. You can't define if a variable is a string or a boolean or a number in XSLT.

    Glad you got it working though!

    Regards,

    Peter

  • Jonas Eriksson 930 posts 1825 karma points
    Feb 18, 2010 @ 15:56
    Jonas Eriksson
    0

    Yeah, thanks, errors of this kind can be really painful sometimes.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies