[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Re: XPath 2.0: Problems with the two boolean const

Subject: RE: Re: XPath 2.0: Problems with the two boolean constants true and false
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 9 Oct 2003 01:12:48 -0700 (PDT)
xsl param boolean
> >  
> >  So what is the benefit of typing? In this case it simply does 
> >  not work and I have to do it myself in code -- I am forced to 
> >  produce ugly code because the so advertised typing does not work.
> 
> There's a bug in the Saxon implementation, I don't see how that enables
> you to draw conclusions about the usefulness of facilities in the
> language?

I am referring to the situation after the bug is corrected.

Then, this template:

  <xsl:template name="And" match="test:*">
    <xsl:param name="arg1" as="xs:boolean"/>
    <xsl:param name="arg2"  as="xs:boolean"/>
         <xsl:value-of 
         select="$arg1 and $arg2"/>
  </xsl:template>

when instantiated with:

   <xsl:apply-templates select="document('')/*/test:*[1]">
     <xsl:with-param name="arg1" select="'false'"/>
     <xsl:with-param name="arg2" select="'true'"/>
   </xsl:apply-templates>

will raise an error, because the arguments are strings, but the parameters
of the template are of type xs:boolean.

Therefore, I am forced to remove the types for the parameters of the
template and do the conversion myself:

  <xsl:template name="And" match="test:*">
    <xsl:param name="arg1"/>
    <xsl:param name="arg2"/>
    <xsl:value-of 
         select="xs:boolean(xs:boolean($arg1) and xs:boolean($arg2))"/>
  </xsl:template>

As I said earlier, this would not be the case if the values of a boolean
were 0 and 1. 

Then I could have:

  <xsl:template name="And" match="test:*">
    <xsl:param name="arg1" as="xs:boolean"/>
    <xsl:param name="arg2"  as="xs:boolean"/>
         <xsl:value-of 
         select="$arg1 and $arg2"/>
  </xsl:template>

and instantiating it like this would not produce any errors:

 
   <xsl:apply-templates select="document('')/*/test:*[1]">
     <xsl:with-param name="arg1" select="0"/>
     <xsl:with-param name="arg2" select="1"/>
   </xsl:apply-templates>


The problem is that the boolean value produced by the template is assigned
to an untyped variable (because the instantiating code is generic and
cannot know the type of values produced by the template it instantiates).

Then, at a further moment in time this variable (in our case having a
value of 'false') is passed as one of the parameters to the 'And'
template.

At this moment the error will be raised that a string was passed when an
xs:boolean was expected.




=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.