Friday, January 17, 2014

XQuery - Solution for "unbound current node is not supported for XQuery resources"

When below error occurs please check whether the string constant is enclosed with single quate(') such that it can be parsed by the XQyuery compiler

Multiple markers at this line - An error occurred compiling the XQuery resource: The use of an unbound current node is not supported for XQuery resources

Simple XQuery function example with constant and if else condition:

declare function xf:passCurrency(
    $price as xs:string)
    as xs:string {
   
    return if (fn:starts-with($price,"$"))
       then 'Dollar'
       else 'Ruppes'

};

7 comments:

  1. I also got this error when I forgot to put a $ sign in front of a variable

    ReplyDelete
  2. I also got this error when I forgot to put a $ sign in front of a variable. this works out.

    ReplyDelete
  3. let $tpye := if (fn:data($result="true"))
    then
    'success'
    else
    'failed'
    Can u pls help us... , I am getting this erorr "The use of an unbound current node is not supported for XQuery resources"

    ReplyDelete
  4. thanks a lot for the help. it was because of the $

    ReplyDelete
  5. I've also had this when referencing an Xml element but getting the case of one of the characters wrong.

    ReplyDelete