xquery try/catch block

Anonymous
2010-09-09
2012-10-08
  • Anonymous - 2010-09-09

    hi

    I am trying to make an try/catch block, and in zorba it works, but I need to
    make it in saxon.

    "try/catch expressions are not allowed in XPath".

    try {
        doc("nenexistent.xml")
    } catch * ($code) {
        <error code="{$code}">file not found</error>
    }
    

    this is expected:

    <error code="err:FODC0002">file not found</error>
    

    but in saxon i get:

    Error on line 2 column 1 of test.xq:
      XPST0003: XQuery syntax error in #
    try {
        doc#:
    

    try/catch expressions are not allowed in XPath
    Static error(s) in query
    Java Result: 2

     
  • Michael Kay

    Michael Kay - 2010-09-09

    try/catch is new in XQuery 1.1, and is not defined for use in XPath/

    Saxon 9.2 implements a subset of the proposed syntax, described here:

    http://www.saxonica.com/documentation/using-
    xquery/xquery11support/trycatch.html

    To use it you must specify xquery version 1.1 in the query prolog, and also
    enable XQuery 1.1 support in the API or command line; and you must be using
    Saxon-PE or Saxon-EE.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks