Re: [xslt] possible bug in functions



Dan Allen wrote:
> I may have discovered a bug with functions when returning boolean values.  Do
> the following test.  Create a variable as such:
> 
> <xsl:variable name="foo" select="false"/>
> 
> then do
> 
> <xsl:if test="$foo">
>   <xsl:text>I see this as true</xsl:text>
> </xsl:if>
> 
> That works fine. 

Ah, but does it do what you _think_ it does?
I believe what it does is find any elements <false> in the
context.  Presumably it doesn't find any, so
that $foo is `empty' and so the test evaluates to false.

There aren't any boolean literals in XSL; what you want are the
functions true() and false().

  Now, write a function like this:
> 
> <func:function name="foo">    
>   <func:result>
>     <xsl:value-of select="false"/>
>   </func:result>
> </func:function>
> 
> then do this
> 
> <xsl:if test="foo()">
>   <xsl:text>I see this as true</xsl:text>
> </xsl:if>
> 
> That does not work, you get the  message when you should not.

Hmm, unless there _are_ some <false> nodes floating around, this
should also "work", but still for the wrong reason.
So maybe there is a bug? (or is there some special interpretation
in functions?)


> Dan
> 
> "I used to herd dairy cows.  Now I herd lusers.  Apart from the isolation,
> I think I preferred the cows.  They were better conversation, easier to
> milk, and if they annoyed me enough, I could shoot them and eat them."
> 
> -------------------------------------------------
> IMP: http://horde.org/imp/       Free the Source!
> _______________________________________________
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> xslt@gnome.org
> http://mail.gnome.org/mailman/listinfo/xslt
> 






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]