Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > b3bdfe6d859a3d6920ff2c44b38e9a6f > files > 236

saxon-manual-9.4.0.9-2.mga7.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="expressions" page="literals" subpage=""/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: Constants</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title" content="Saxonica: XSLT and XQuery Processing: Constants"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Constants</h1>
      <p><b>String literals</b> are written as "London" or 'Paris'. In each case you can use the opposite
kind of quotation mark within the string: 'He said "Boo"', or "That's rubbish". In a stylesheet
XPath expressions always appear within XML attributes, so it is usual to use one kind of delimiter for
the attribute and the other kind for the literal. Anything else can be written using XML character
entities. In XPath 2.0, string delimiters can be doubled within the string to represent the
delimiter itself: for example <code>&lt;xsl:value-of select='"He said, ""Go!"""'/&gt;</code></p>
      <p><b>Numeric constants</b> follow the Java rules for decimal literals: for example, <code>12</code> or <code>3.05</code>; a
negative number can be written as (say) <code>-93.7</code>, though technically the minus sign is not part of the
literal. (Also, note that you may need a space before the minus sign to avoid it being treated as
a hyphen within a preceding name). The numeric literal is taken as a double precision floating 
point number if it uses scientific notation (e.g. <code>1.0e7</code>), as fixed point decimal
if it includes a full stop, or as a integer otherwise. Decimal values (and integers) in Saxon have unlimited 
precision and range (they use the Java classes BigInteger and BigDecimal internally). Note that a value 
such as <code>3.5</code> was
handled as a double-precision floating point number in XPath 1.0, but as a decimal number in
XPath 2.0: this may affect the precision of arithmetic results.</p>
      <p>There are no boolean constants as such: instead use the function calls <code>true()</code> and 
<code>false()</code>.</p>
      <p>Constants of other data types can be written using constructors, which look like function calls
but require a string literal as their argument. For example, <code>xs:float("10.7")</code> produces
a single-precision floating point number. Saxon implements constructors for all of the built-in data types
defined in XML Schema Part 2.</p>
      <p>An example for <b>date</b> and <b>dateTime</b> values: 
you can write constants for these data types as <code>xs:date("2002-04-30")</code>
or <code>xs:dateTime("1966-07-31T15:00:00Z")</code>.</p>
      <p>XPath 2.0 allows the argument to a constructor to
contain whitespace, as determined by the whitespace facet for the target data type.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="variables.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>