This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Boolean true() and false() as strings?
- To: xsl-list at mulberrytech dot com
- Subject: Re: Boolean true() and false() as strings?
- From: Wendell Piez <wapiez at mulberrytech dot com>
- Date: Thu, 05 Oct 2000 17:41:34 +0100
- Reply-To: xsl-list at mulberrytech dot com
John--
It's not the boolean test that's coercing $units_gt_300 to a string ...
it's the original <xsl:value-of select="true()"/> -- or false() -- that
creates it....
"The xsl:value-of element is instantiated to create a text node in
the result tree. The required select attribute is an expression;
this expression is evaluated and the resulting object is converted
to a string as if by a call to the string() function." [XSLT 7.6.1]
Note this is different from saying
<xsl:variable name="units_gt_300" select="true()"/>
where the assigned value is the Boolean.
Obscure little corners of the spec....
Cheers,
Wendell
At 04:17 PM 10/5/00 -0400, you wrote:
>A curious thing (well, to me!)... consider this template rule:
>
><xsl:template match="sales">
> <h2>Regions Selling More than 300 Units:</h2>
> <xsl:for-each select="region">
> <xsl:variable name="units_gt_300">
> <xsl:choose>
> <xsl:when test="number(units) > 300">
> <xsl:value-of select="true()"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="false()"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:variable>
> <xsl:if test="$units_gt_300='true'">
> <h3><xsl:value-of select="concat(@name, ' (', units, '
units)')"/></h3>
> </xsl:if>
> </xsl:for-each>
></xsl:template>
>
>Note the assignment of Boolean true() or false() to the variable, and the
><xsl:if> test. Why can't the latter be simply:
>
> <xsl:if test="$units_gt_300">
>
>i.e., why the need to test vs. the string value "true"? Does using the
>true() and false() functions in a variable coerce their return values to
>string type rather than their "native" Boolean?
======================================================================
Wendell Piez mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list