[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Failing string() test fail


Subject: Re: [xsl] Failing string() test fail
From: Karl Stubsjoen <kstubs@xxxxxxxxx>
Date: Thu, 25 Jun 2009 23:37:15 -0700

Correct, one Yes.  That is what I would expect.  So wondering why I am
having a problem with my XML source.

On Thu, Jun 25, 2009 at 11:15 PM, Vyacheslav
Sedov<vyacheslav.sedov@xxxxxxxxx> wrote:
> "You get one Yes". is out of xsl:if element
>
> On Fri, Jun 26, 2009 at 10:09 AM, Christopher R. Maden <crism@xxxxxxxxx>
wrote:
>>
>> Karl Stubsjoen wrote:
>> > What would cause a string() test to fail?  I've tested on a simple
>> > xml, like this, with the following test:
>> >
>> > Assume we are matching on B
>> >
>> > <xsl:if test="string(C/@test)">Yes</xsl:if> You get one Yes.
>> >
>> > <A>
>> >     <B>
>> >         <C/>
>> >         <C/>
>> >         <C/>
>> >     </B>
>> >     <B>
>> >         <C/>
>> >         <C test="yes"/>
>> >         <C/>
>> >     </B>
>> > </A>
>>
>> What would you expect to get?
>>
>> Remember that in the context of xsl:if test, there is a coercion to
>> Boolean.  When there is no @test attribute, the string() will evaluate
>> to the empty string, which in turn evaluates to false.  So I would
>> expect no Yes for the first <B> and a Yes for the second <B>.
>>
>> ~Chris
>> --
>> Chris Maden, text nerd  <URL: http://crism.maden.org/ >
>> All I ask of living is to have no chains on me,
>>  And all I ask of dying is to go naturally.  Laura Nyro
>> GnuPG Fingerprint: C6E4 E2A9 C9F8 71AC 9724 CAA3 19F8 6677 0077 C319


Current Thread
Keywords
xml