XQuery中变量“per”不在范围内错误

XQuery中变量“per”不在范围内错误,xquery,Xquery,当我试图在Java中执行下面的代码时,我遇到了“not in scope error”错误中的“Variable” String xq = "declare variable $per1 as document-node(element(*, xs:untyped)) := " + "fn:parse-xml($per);" + "declare variable $job1 as document-node(element(*, xs:untyped)) := fn:parse

当我试图在Java中执行下面的代码时,我遇到了“not in scope error”错误中的“Variable”

  String xq = "declare variable $per1 as document-node(element(*, xs:untyped)) := " +
    "fn:parse-xml($per);" +
  "declare variable $job1 as document-node(element(*, xs:untyped)) := fn:parse-xml($job);" +
    "for $i in $per1//pimergednodes/Get__CompIntfc__CI_PERSONAL_DATAResponse,\n" + 
  "         $j in $job1//jobmergednodes/Get__CompIntfc__CI_JOB_DATAResponse[PROP_EMPLID = $i/PROP_EMPLID]\n" + 
  "\n" + 
  "     return\n" + 
  "        <emp>\n" + 
  "        {\n" + 
  "           $i/PROP_EMPLID,\n" + 
  "           $i/PROP_BIRTHDATE,\n" + 
  "           <coll_names>\n" + 
  "           {\n" + 
  "           $i/COLL_NAME_TYPE_VW/COLL_NAMES\n" + 
  "           }\n" + 
  "           </coll_names>,\n" + 
  "\n" + 
  "           $i/PROP_BIRTHDATE/COLL_NAME_TYPE_VW/PROP_FIRST_NAME,\n" + 
  "           $j/COLL_JOB/PROP_DEPTID\n" + 
  "\n" + 
  "           }\n" + 
  "        </emp>";

  XQDataSource xds = new oracle.xquery.xqj.OXQDataSource();
  XQConnection conn = xds.getConnection();
  XQPreparedExpression pEx = conn.prepareExpression(xq); ==> error raised in this call.
有人能帮我纠正这个错误吗

提前感谢,,
Maviswa

您在fn:parse xml$per中引用了$per,但您的代码没有在任何地方定义该变量。我看到每1美元,但没有每1美元。我怀疑你在$job上也会遇到同样的问题


为了进行调试,请打印出xq字符串,这样您就可以在不转义所有Java字符串的情况下单独查看XQuery,这只会增加很多噪音。

我感觉您试图将$per和$job从Java上下文传递到XQuery上下文中。您需要做更多的工作,比如将它们声明为外部对象,并以某种方式将它们传递给XQuery Java对象。也可以将文本XML连接到查询中。。