Scope of variables in XQuery?

Viewed 713

I have note.xml:

<?xml version="1.0"?>
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>

and note.xqy:

let $srcDoc:="note.xml"
for $x in doc($srcDoc)/note
return (),

for $x in doc($srcDoc)/note
return ()

For some reasons I need two fors to process note.xml. I don't want to write the processed file name two times, so I define a variable. Strange is, the variable is not defined in the second for:

$ zorba -i -f -q note.xqy
note.xqy>:5,15: static error [err:XPST0008]: "srcDoc": undeclared variable
1 Answers
Related