Working directory of a framework-based xquery script

Post here questions and problems related to oXygen frameworks/document types.
afuchs
Posts: 25
Joined: Mon May 19, 2014 11:38 am

Working directory of a framework-based xquery script

Post by afuchs »

Good day,

I am developing a framework for a project that contains around 2000 XML files tucked into different subdirectories of the project.
The framework must include a variety of xquery scripts to generate different kinds of reports, indexes etc. for this data, i.e. cull information from the collection of files, pack it up as an XML and present it in a tab, where it can be used and processed in the same framework. The scripts should be accessible as author actions / buttons on the toolbar.

My difficulty is to pass the project directory to the xquery script, which I have included in the framework as a "transformation scenario". The configuration of the scenario allows either a specific file as input, or nothing. In the latter case, the working directory is the directory of the framework resource (doesn't help me), in the former case the working directory may be any of the subdirectories of the project (complicated).

My workaround at present is placing a dummy file in the project directory and naming it as input, then extricating its path. This is somewhat inconvenient.

Using parameters is difficult because the project is distributed to users who may put it anywhere in their environments. But there is always a project with an XPR file along with it.

Is there a more straightforward way to pass the project directory to a transformation scenario in aframework?
Radu
Posts: 9477
Joined: Fri Jul 09, 2004 5:18 pm

Re: Working directory of a framework-based xquery script

Post by Radu »

Hi,
In general in an XQuery transformation scenario when you define the XML document path or a value for a parameter you can use editor variables, one of those is "${pdu}/" which expands to the URL path or the current opened project.
https://www.oxygenxml.com/doc/versions/ ... ables.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
afuchs
Posts: 25
Joined: Mon May 19, 2014 11:38 am

Re: Working directory of a framework-based xquery script

Post by afuchs »

Hi Radu,

Thank you very much for your prompt reply.
Unfortunately, when I use ${pdu}/ in the XML URL field of the transformation, and then try to access the collection thus:

Code: Select all

  let $refs := collection('./?select=*.xml;recurse=yes')
...I get an error which lists the correct project directory but says "is a directory".
And only if I name a dummy file inside the project directory in the URL XML field, such as "${pdu}/dummy.xml", then use

Code: Select all

 let $refs := collection(concat(replace(document-uri(.), '(/)[^/]*$', '$1'),'?select=*.xml;recurse=yes'))
I can access the collection from the right directory.

Am I missing some part of the transformation configuration which would allow to passing a directory, not a file?
Radu
Posts: 9477
Joined: Fri Jul 09, 2004 5:18 pm

Re: Working directory of a framework-based xquery script

Post by Radu »

Hi,
There should already be some kind of "project.xpr" XML project configuration file in your project, maybe you can use something like "${pdu}/project.xpr" as the XML input.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply