Page 1 of 1

Perform xquery works in the XQuery builder but not in the Xquery debugger - "Content is not allowed in prolog"

Posted: Thu Apr 16, 2020 1:08 pm
by mrwatson-de
I have an XQuery expression which works in the Query builder, but when I try to do the same in the XQuery debugger I get the error message "Content is not allowed in prolog"

The XQuery is stored in a file "DDR_Text.lines_ListFileTOs.xquery"

It seems to be expecting the XQuery to be XML instead of a simple xquery string, and parsing it.

How can I get the XQuery debugger to behave the same as the XQuery builder?

Thanks for help through these teething troubles!

MrWatson


-------------
Code below:

Code: Select all

(: 0. Output text instead of XML :)
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "text";

for $File in 
(: 1. Drill down to each document of the DDR  or use current doc :)
(/FMPReport/File/@link/doc(.) union doc('')[/FMPReport/@link])

(: 2. Drill down further to the required Catalog :)
/FMPReport/File

let $filename := replace($File/@name,"^(.+?)(\.\w+)?$","$1")

return
(
for $tablename in $File/RelationshipGraph[1]/TableList[1]

(: 3. Find all table occurences :)
/Table/@name ! concat($filename , '::' , data(.))

order by $tablename 

return $tablename
(: 4. Prepend the file name onto each of them :)
)

(: 5. Output the results as a list sep
arated by LF :)
=> fn:string-join('
')

Re: Perform xquery works in the XQuery builder but not in the Xquery debugger - "Content is not allowed in prolog"

Posted: Thu Apr 16, 2020 6:50 pm
by adrian
Hi,
mrwatson-de wrote: Thu Apr 16, 2020 1:08 pm How can I get the XQuery debugger to behave the same as the XQuery builder?
You have to give it the same scope.
Look at the toolbar of the XPath/XQuery builder, it uses the currently selected file from the editing area as the scope. In the debugger you have to select the input XML from the toolbar.

Do note that there is that doc('') which can be troublesome. For more consistent results you might want to try doc(base-uri()) instead.

Regards,
Adrian

Re: Perform xquery works in the XQuery builder but not in the Xquery debugger - "Content is not allowed in prolog"

Posted: Fri Apr 17, 2020 6:45 pm
by mrwatson-de
Hello again Adrian,

thanks very much for your answer.

I did indeed manage to come to the same conclusions today, after I realised that the doc('') was referencing the xquery file rather than the xml file, and thus causing the xquery to be parsed and cause the error.

I tried doc(base-uri(/)) ... but your tip is just perfect - thanks!