Perform xquery on an xml file … WITHOUT a debugger

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

Perform xquery on an xml file … WITHOUT a debugger

Post by mrwatson-de » Thu Apr 16, 2020 12:57 pm

I think I might be missing something in oXygen.

I regularly create XML reports about a database (DDR reports about a FileMaker database) and wish to use oXygen to develop and then frequently apply xquery analyses of those reports.

For example, I've developed an xquery expression to list all of the database's tables and I now want to RUN it to get that information.

Do I have to use the xquery Debugger? (which seems like complete overkill to me)

Or is there a simple "run xquery" button I have not yet found?

Or am I using oXygen in a way it is not [yet] intended to be used?

Thanks for your help.

MrWatson

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

Re: Perform xquery on an xml file … WITHOUT a debugger

Post by adrian » Thu Apr 16, 2020 5:14 pm

Hi,

Considering your other topic, Perform xquery works in the XQuery builder but not in the Xquery debugger - "Content is not allowed in prolog", you have already found the XPath/XQuery Builder (Window > Show View > ...) which does what you were asking.

The alternative is to put the XQuery expression in a file and create a transformation scenario (Document > Transformation > Configure Transformation Scenarios, New > XQuery transformation).

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 on an xml file … WITHOUT a debugger

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

Thanks Adrian,

yeah I battled with the Transformation Scenarios yesterday and couldn't find a suitable solution.

I have hundreds of XMLs and hundreds of XQuery & XSLTs analysis-functions, and I can't (i.e. don't want to have to) create a scenario every time I want to do an analysis on some XML file

I would like to be able to open any XML file and any XQuery & XSLT analysis-function file,

and then - similar to the debugger - press a button "APPLY".

In the scenario window I could only find variables for the current file and the current dbgXSLT, but nothing to reference a current XQUERY.

I have for the moment made an (unsatisfactory) workaround, that I always place the file I want to analyse in a particular path, and then run the sceanrio to apply the currently selected xquery to it.

Do you have any tips?

Thanks very much for your time!

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

Re: Perform xquery on an xml file … WITHOUT a debugger

Post by mrwatson-de » Fri Apr 17, 2020 7:01 pm

Plus ... I have <oXygen/> XML Developer 20.0, build 2018031511 ... and the variables for the files selcted in the debugger do not seem to be available.

Are they first available in a newer version?

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

Re: Perform xquery on an xml file … WITHOUT a debugger

Post by adrian » Thu Apr 23, 2020 5:50 pm

Hello,
In the scenario window I could only find variables for the current file and the current dbgXSLT, but nothing to reference a current XQUERY.
In what context did you find dbgXSL mentioned? Maybe in the documentation?
Despite the name, dbgXSL also resolves to the debugged XQuery.
${dbgXSL} - The local file path to the XSL/XQuery document that is currently selected in the Debugger stylesheet combo box (for tools started from the XSLT/XQuery Debugger).
The bad news is dbgXSL is only available for External Tools that are started in the Debugger perspectives. It is not available for transformation scenarios. I've added an improvement request to discuss if it makes sense to accommodate dbgXML and dbgXSL in scenarios, since scenarios aren't really meant for the debugger perspective.
I have hundreds of XMLs and hundreds of XQuery & XSLTs analysis-functions, and I can't (i.e. don't want to have to) create a scenario every time I want to do an analysis on some XML file
You only need one scenario that can be reused/edited, but since what you apply with it is fixed, it should be created so that ${currentFileURL} is the file that most frequently changes (e.g. XML), and only change the XQuery.
So, if you have an XQuery that you want to run on many XMLs, open an XML and create a scenario of type "XML transformation with XQUERY", leave the "XML URL" set to ${currentFileURL} and pick the XQuery. If the XQuery document is open, you can quickly select it from the combo list.
So, you can now use this scenario to apply the selected XQuery on any open XML. You may want to use the Transformation Scenarios view (Window > Show View > ...) to easily select and run the scenario from the list.
When you want to apply a different XQuery, open that XQuery, select back an XML, select and edit the reusable scenario (Edit button in Transformation Scenarios view toolbar) and pick from the XQuery URL combo list your newly opened XQuery. Once you get used to it, it takes maybe 3-4 clicks to change the XQuery from the scenario.
I have for the moment made an (unsatisfactory) workaround, that I always place the file I want to analyse in a particular path, and then run the sceanrio to apply the currently selected xquery to it.
You seem to have already tried the opposite, a scenario from the XQuery perspective, "XQuery transformation " with "XQuery URL" set to ${currentFileURL} and you keep changing the XML. Wouldn't it be simpler to edit the scenario and select the XML from the scenario combo list, rather than moving the XML to a specific location?

Transformation scenarios are meant to work "1 to many", 1 specific XSLT/XQuery to many XMLs, or the opposite, 1 specific XML to many XSLT/XQuery. They can also be used in batch transformations (select a folder or multiple files in the Project view, right click and see Transform submenu), if that's of any use to you.

Other than that, I don't have a proper solution for such use case.
The debugger is the fastest way of picking both files, but is the slowest to run, as it is quite heavy. Use the "Link with Editor" option (to the right of the XQuery combo list), so that the currently selected editors are automatically picked as XML and XQuery inputs. Use Run to End (Alt-F5) to run it without stopping.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Post Reply