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

Issues related to W3C XQuery.
mrwatson-de
Posts: 5
Joined: Thu Apr 16, 2020 12:48 pm

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

Post by mrwatson-de » Thu Apr 16, 2020 1:08 pm

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('
')

adrian
Posts: 2666
Joined: Tue May 17, 2005 4:01 pm

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

Post by adrian » Thu Apr 16, 2020 6:50 pm

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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

mrwatson-de
Posts: 5
Joined: Thu Apr 16, 2020 12:48 pm

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

Post by mrwatson-de » Fri Apr 17, 2020 6:45 pm

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!

Post Reply