Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The value of the $var variable as defined in:</p> <p>&nbsp;&nbsp;&nbsp;<code>&lt;xsl:variable name="var" select="boolean('false')"/&gt;</code></p> <p>is </p> <p>&nbsp;&nbsp;&nbsp;<strong><code>true()</code></strong></p> <p>This is because in XPath "<code>false</code>" is an ordinary string, as opposed to <code>false()</code>, which is the constructor for the <code>boolean</code> value <code>false()</code></p> <p><strong>The two boolean values in XPath are</strong> (note that they are constructed!):</p> <p>&nbsp;&nbsp;&nbsp;<strong><code>true()</code></strong> and <strong><code>false()</code></strong></p> <p>The detail of converting any value to boolean are spelled outin the <a href="http://www.w3.org/TR/xpath#section-Boolean-Functions" rel="noreferrer">XPath Spec</a>.:</p> <p>"The <a href="http://www.w3.org/TR/xpath#function-boolean" rel="noreferrer"><strong>boolean</strong></a> function converts its argument to a boolean as follows:</p> <ul> <li><p>a number is true if and only if it is neither positive or negative zero nor NaN</p></li> <li><p>a node-set is true if and only if it is non-empty</p></li> <li><p>a string is true if and only if its length is non-zero</p></li> <li><p>an object of a type other than the four basic types is converted to a boolean in a way that is dependent on that type "</p></li> </ul> <p>In your case the string "false" is not the number 0 and has a positive length, so the rule in the 3rd bullet above is applied, yielding <code>true()</code>.</p> <p><strong>Therefore, to define a variable in XSLT 1.0, whose value is</strong> <a href="http://www.w3.org/TR/xpath#function-false" rel="noreferrer"><strong><code>false()</code></strong></a>, one needs to write the definition as the following:</p> <p>&nbsp;&nbsp;&nbsp;<code>&lt;xsl:variable name="vMyVar" select="false()"/&gt;</code></p> <p>or, if you don't exactly remember this, you could always write:</p> <p>&nbsp;&nbsp;&nbsp;<code>&lt;xsl:variable name="vMyVar" select="1 = 0"/&gt;</code></p> <p>(specify any expression that evaluates to <code>false()</code>) and the XSLT processor will do the work for you.</p> <p><strong>In XSLT 2.0 it is always better to explicitly specify the type</strong> of the variable:</p> <p>&nbsp;&nbsp;&nbsp;<code>&lt;xsl:variable name="vMyVar" as="xs:boolean" select="false()"/&gt;</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload