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

Re: [xsl] A smarter choose operation XSL 1.1


Subject: Re: [xsl] A smarter choose operation XSL 1.1
From: Karl Stubsjoen <kstubs@xxxxxxxxx>
Date: Tue, 16 Jun 2009 10:45:13 -0700

Disregard Nan issue for number($optional.one), it was misuse of the
string() function which needs a boolean operation first before the
number operation.

So I had:
<xsl:variable name="optional.one" select="string(firstName)"/>

I needed:
<xsl:variable name="optional.one" select="boolean(string(firstName))"/>


Karl..

On Tue, Jun 16, 2009 at 10:25 AM, Karl Stubsjoen<kstubs@xxxxxxxxx> wrote:
> Also,
>
> I am getting Nan for:
> number($optional.one)
>
> Is that expected?  It seems that I am not having success with this
> approach either.
>
> Karl..
>
> On Tue, Jun 16, 2009 at 9:58 AM, Karl Stubsjoen<kstubs@xxxxxxxxx> wrote:
>> 2 Things.  What is prefix "vrtf" stand for and is and is the variable
>> defined as vOne correct?
>>
>>      <xsl:template match="/">
>>        <xsl:variable name="vOne" select=
>>        "document('')/*/xsl:variable[@name='vrtfOne']"
>>        />
>>
>> I do not see a template level variable named "vrtfOne"
>>
>> Thanks,
>>
>> Karl..
>>
>> On Thu, Jun 11, 2009 at 4:35 PM, Dimitre Novatchev<dnovatchev@xxxxxxxxx>
wrote:
>>> On Thu, Jun 11, 2009 at 1:45 AM, David Carlisle<davidc@xxxxxxxxx> wrote:
>>>>
>>>> Another xslt1 version (as for Dimitre's this works also in xslt2 as
>>>> written, with version="1.0" but if you make it version="2.0" and turn
off
>>>> backward compatibilty mode, you get a type error).
>>>
>>> Yes, both David's solution and mine cause a type error to be raised if
>>> they use version="2.0" and an XSLT 2.0 processor.
>>>
>>> This one performs with both versions without any error:
>>>
>>> <xsl:stylesheet version="2.0"
>>>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>>>  <xsl:output method="text"/>
>>>
>>>  <xsl:variable name="vrtfResults">
>>>  <r>1</r>
>>>  <r>1.70</r>
>>>  <r>2.25</r>
>>>  <r>3</r>
>>>  </xsl:variable>
>>>
>>>  <xsl:param name="optional.one" select="true()" />
>>>  <xsl:param name="optional.two" select="true()" />
>>>  <xsl:param name="optional.three" select="true()" />
>>>
>>>
>>>       <xsl:template match="/">
>>>         <xsl:variable name="vOne" select=
>>>         "document('')/*/xsl:variable[@name='vrtfOne']"
>>>         />
>>>         <xsl:variable name="vResults" select=
>>>         "document('')/*/xsl:variable[@name='vrtfResults']/*"
>>>         />
>>>
>>>         <xsl:value-of select=
>>>         "$vResults[number($optional.one)
>>>                  + number($optional.two)
>>>                  + number($optional.three)
>>>                  + 1
>>>                   ]"/>
>>>       </xsl:template>
>>> </xsl:stylesheet>
>>>
>>>
>>>
>>> --
>>> Cheers,
>>> Dimitre Novatchev
>>> ---------------------------------------
>>> Truly great madness cannot be achieved without significant intelligence.
>>> ---------------------------------------
>>> To invent, you need a good imagination and a pile of junk
>>> -------------------------------------
>>> Never fight an inanimate object
>>> -------------------------------------
>>> You've achieved success in your field when you don't know whether what
>>> you're doing is work or play


Current Thread
Keywords