Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > b3bdfe6d859a3d6920ff2c44b38e9a6f > files > 346

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="extensions" page="functions" subpage="try"/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: saxon:try()</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title" content="Saxonica: XSLT and XQuery Processing: saxon:try()"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>saxon:try()</h1>
      <p><i>This function is available only in Saxon-EE</i></p>
      <p>This function provides a simple way of recovering from dynamic errors (including type
errors). </p>
      <p><b>try($arg1 as item()*, $arg2 as item()*) ==&gt; item()*</b></p>
      <p>This returns the value of the first argument, unless evaluation of the first argument
fails. If a failure occurs, then the second argument is evaluated and its value is returned.</p>
      <p>Here is an example showing the simpler form of call: the expression
<code>saxon:try(1 div 0, "divide by zero")</code> returns the string "divide by zero".</p>
      <p>To recover from failures occurring in XSLT instructions, for example schema validation errors,
wrap the instructions in a stylesheet function (<code>xsl:function</code>) and call this function
within a call of <code>saxon:try()</code>.</p>
      <div class="boxed"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">The ability to supply a function value as the second argument is withdrawn in Saxon 9.2.</div>
      <p><i>In XSLT, a more flexible mechanism for catching errors is the <a class="bodylink" href="../../extensions/instructions/try-instr.xml">saxon:try</a>
  extension instruction. In XQuery, a more flexible mechanism is the XQuery 1.1 <code>try{}</code> expression.</i></p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="typeannotation.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>