Re: How to pass a boolean value true or false using with-param when the required param type is xs:boolean;

Okay thanks much, I guess I'll go for using strings for now given the
platform might change in the future. Seems like a non-standard extension
that would be better a standard one given that it makes working with
existing style sheets easier.


On Thu, Nov 12, 2009 at 7:36 PM, Leif Warner <abimelech@gmail.com> wrote:

> I was just going to mention to mention that XProc parameters are limited to
> strings.  There's a Calabash option that changes that, as mentioned here:
> http://norman.walsh.name/2009/06/23/notXProc
> I got your case to run with the "-X general-values" command-line flag.
> -Leif
>
>
> On Thu, Nov 12, 2009 at 11:18 AM, James Sulak <jsulak@gmail.com> wrote:
>
>> I'm afraid you'll probably have to do something like this in your
>> transform if you want to get a boolean:
>>
>> <xsl:param name="preserve_newline" as="xs:boolean"/>
>> <xsl:variable name="preserve_newline_boolean"
>> select="upper-case($preserve_newline) = 'TRUE'" as="xs:boolean" />
>>
>> And then use $preserve_newline_boolean where you were using
>> $preserve_newline.
>>
>> I think what it comes down to is that while XSL allows parameters of
>> any type, XProc limits parameters to being strings, and will pass them
>> as strings to an XSL. So the XSL will recieve a string when it is
>> expecting a boolean, and fail.  It's kind of an annoying limitation in
>> situations like this.
>>
>> Hope this helps,
>>
>> -James
>>
>>
>>
>> On Thu, Nov 12, 2009 at 12:36 PM, Alex Muir <alex.g.muir@gmail.com>
>> wrote:
>> > James,
>> >
>> > Well mixed results.  I removed the  as="xs:boolean" (although really it
>> > should work with it there right?) to then have in the style sheet
>> >
>> >  <xsl:param name="preserve_newline" />
>> >
>> > which removed the error message in the xproc.  I then tried various
>> values
>> > to find that true() which was true, false() was also true, any quoted
>> text
>> > was true and non quoted text was false.
>> >
>> >
>> >              <!-- true() = true-->
>> >              <!-- false() = true -->
>> >             <!--  false = false-->
>> >             <!--  true = false-->
>> >             <!--  junk = false-->
>> >             <!-- 'true' = true -->
>> >             <!-- 'false' = true -->
>> >
>> > <p:with-param name="preserve_newline" select="false()"/>
>> >
>> >                 is not working as I would expect it to.
>> >
>> >
>> > My style sheet is working correctly when I put select="true()" or
>> false()
>> > into the parameter directly in the style sheet and remove the with-param
>> > statement from the xproc.
>> >
>> >
>> > Alex
>> >
>> > On Thu, Nov 12, 2009 at 5:35 PM, James Sulak <jsulak@gmail.com> wrote:
>> >>
>> >> My understanding is that parameters in XProc must be strings (or
>> >> xs:untypedAtomics), per section 2.11.  So even though the transform
>> >> declares the parameter as an "xs:boolean," XProc is passing the
>> >> parameter as a string.  If you remove the type from the XSL parameter
>> >> declaration, does it work?
>> >>
>> >> -James
>> >>
>> >> On Thu, Nov 12, 2009 at 11:17 AM, Alex Muir <alex.g.muir@gmail.com>
>> wrote:
>> >> > Toman,
>> >> >
>> >> > I get the same error message with that statement.
>> >> >
>> >> > Description:  Required type is xs:boolean; supplied value has type
>> >> > xs:string
>> >> >
>> >> > Alex
>> >> >
>> >> > On Thu, Nov 12, 2009 at 5:00 PM, <Toman_Vojtech@emc.com> wrote:
>> >> >>
>> >> >> Alex,
>> >> >>
>> >> >> It seems to me that the problem is that there is no implicit
>> readable
>> >> >> port
>> >> >> to which the p:with-param can connect to - and therefore you get a
>> >> >> static
>> >> >> error. Try this:
>> >> >>
>> >> >> <p:with-param name="preserve_newline" select="false()">
>> >> >>   <p:empty/>
>> >> >> </p:with-param>
>> >> >>
>> >> >> Regards,
>> >> >> Vojtech
>> >> >>
>> >> >> ________________________________
>> >> >> From: xproc-dev-request@w3.org [mailto:xproc-dev-request@w3.org] On
>> >> >> Behalf
>> >> >> Of Alex Muir
>> >> >> Sent: Thursday, November 12, 2009 5:43 PM
>> >> >> To: xproc-dev@w3.org
>> >> >> Subject: How to pass a boolean value true or false using with-param
>> >> >> when
>> >> >> the required param type is xs:boolean;
>> >> >>
>> >> >> Hi
>> >> >>
>> >> >> In the following xproc the <p:with-param name="preserve_newline"
>> >> >> select="false()"/> gives me an error message
>> >> >>
>> >> >>  "Description:  Required type is xs:boolean; supplied value has type
>> >> >> xs:string"
>> >> >>
>> >> >> because the style sheet is expecting
>> >> >>
>> >> >> <xsl:param name="preserve_newline" as="xs:boolean"/>.
>> >> >>
>> >> >> It's funny to be asking this question but how do I specify the
>> boolean
>> >> >> value false in the xproc with-param ? I tried false, false() and 0
>> but
>> >> >> there
>> >> >> all treated as strings giving the same error message.
>> >> >>
>> >> >>    <p:xslt name="DoSomething">
>> >> >>       <p:input port="source"/>
>> >> >>       <p:input port="stylesheet">
>> >> >>         <p:document href="doSomething.xsl"/>
>> >> >>       </p:input>
>> >> >>
>> >> >>       <p:with-param name="preserve_newline" select="false()"/>
>> >> >>
>> >> >>       <p:input port="parameters">
>> >> >>         <p:empty/>
>> >> >>       </p:input>
>> >> >>     </p:xslt>
>> >> >>
>> >> >>
>> >> >> Thanks Much
>> >> >>
>> >> >> --
>> >> >>
>> >> >> Alex
>> >> >> https://sites.google.com/a/utg.edu.gm/alex
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> >
>> >> > Alex
>> >> > https://sites.google.com/a/utg.edu.gm/alex
>> >> >
>> >> >
>> >
>> >
>> >
>> > --
>> >
>> > Alex
>> > https://sites.google.com/a/utg.edu.gm/alex
>> >
>> >
>>
>>
>


-- 

Alex
https://sites.google.com/a/utg.edu.gm/alex

Received on Thursday, 12 November 2009 19:48:59 UTC