[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: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 9 Oct 2003 14:44:29 +0100
xs boolean values
Hi Dimitre,

> But if the Data Model were saying that 0 and 1 are not simply
> "string representations" (note that I didn't use '0' and '1' in my
> previous example but just 0 and 1 -- that is not the strins '0' and
> '1') but that 0 and 1 are *the* two xs:boolean constants,
>
> then
>
> it would make difference as the result of evaluating a boolean
> expression would be not a "representation" but a real (or native, or
> genuine) boolean value.
>
> Isn't it natural for a type to have its own genuine values and not
> only a "representation"?

Of course. But that's what we have currently, isn't it? The result of
the expression:

  true() and false()

is a native xs:boolean value, false, not the string 'false'.

Perhaps you're finding problems because:

  <xsl:value-of select="true() and false()" />

generates a text node whose string value is the result of converting
the xs:boolean value false to a string (i.e. 'false')?

Perhaps you would be better off using:

  <xsl:sequence select="true() and false()" />

which actually adds the xs:boolean value false to the result sequence.

In other words, use a template along the lines of:

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

Note that here the template is declared to have an xs:boolean value as
its result; that declarations isn't completely necessary (it will
still have an xs:boolean value as its result without it), but it's
good practice.

(Returning the actual xs:boolean value should also be more efficient
since you're not having to create any nodes that way --
<xsl:value-of>, theoretically at least, creates a text node.)

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.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.