Passing directory parameter to Xquery from Trans Scenario
Issues related to W3C XQuery.
-
- Posts: 5
- Joined: Thu Oct 03, 2013 1:37 am
Passing directory parameter to Xquery from Trans Scenario
Post by wolandscat »
Oxygen 15 / Windows 7
I have an Xquery that starts with the statement:
for $file in collection("../test_set_001/?select=*.xml");
this finds all the XML files in the directory test_set_001 and runs the remaining statements on them.
What I really want is to be able to set up different Transform scenarios which reference different test set directories.
So I set up a parameter {test_set} and give it value 'test_set_001'
Now I want to replace the above 'collection' statement with one that takes the parameter e.g. something like
for $file in collection (concat ('../', ${test_set}, '?select=*.xml'));
This won't compile. If I put ${test_set} in quotes it doesn't get replaced. This should be simple I guess, but it's not clear from the documentation how substitution works...
any help appreciated.
- thomas
I have an Xquery that starts with the statement:
for $file in collection("../test_set_001/?select=*.xml");
this finds all the XML files in the directory test_set_001 and runs the remaining statements on them.
What I really want is to be able to set up different Transform scenarios which reference different test set directories.
So I set up a parameter {test_set} and give it value 'test_set_001'
Now I want to replace the above 'collection' statement with one that takes the parameter e.g. something like
for $file in collection (concat ('../', ${test_set}, '?select=*.xml'));
This won't compile. If I put ${test_set} in quotes it doesn't get replaced. This should be simple I guess, but it's not clear from the documentation how substitution works...
any help appreciated.
- thomas
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Passing directory parameter to Xquery from Trans Scenari
Hi,
Declare test_set as an external variable:
Then use it as any other variable:
You can specify the value of test_set when editing the transformation scenario configuration (press the Parameters button).
Regards,
Adrian
Declare test_set as an external variable:
Code: Select all
declare variable $test_set as xs:string external;
Code: Select all
for $file in collection (concat ('../', $test_set, '?select=*.xml'))
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 5
- Joined: Thu Oct 03, 2013 1:37 am
Re: Passing directory parameter to Xquery from Trans Scenari
Post by wolandscat »
Hi,
thanks for the answer. I have added the declaration to the xquery.
In the transformation scenario, I added a variable 'test_set' and a value for it. (It's not clear whether it should be 'test_set', '{test_set}', '$test_set', '${test_set}' or something else).
When I run the scenario, I get the error:
....
Engine name: Saxon-PE XQuery 9.5.0.2
Severity: error
Description: XPDY0002: No value supplied for required parameter $test_set
Start location: 2:0
URL: http://www.w3.org/TR/xpath20/#ERRXPDY0002
However, the query does appear to actually work. I set up another transformation scenario, with a different parameter value. It also generates the same error, but then appears to work.
What should I make of this?
- thomas
thanks for the answer. I have added the declaration to the xquery.
In the transformation scenario, I added a variable 'test_set' and a value for it. (It's not clear whether it should be 'test_set', '{test_set}', '$test_set', '${test_set}' or something else).
When I run the scenario, I get the error:
....
Engine name: Saxon-PE XQuery 9.5.0.2
Severity: error
Description: XPDY0002: No value supplied for required parameter $test_set
Start location: 2:0
URL: http://www.w3.org/TR/xpath20/#ERRXPDY0002
However, the query does appear to actually work. I set up another transformation scenario, with a different parameter value. It also generates the same error, but then appears to work.
What should I make of this?
- thomas
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Passing directory parameter to Xquery from Trans Scenari
If you have declared the variable as external in XQuery, Oxygen should have already presented its name when you pressed the Parameters button (when configuring the scenario). So you shouldn't have to manually enter its name, it should already be in the list of parameters. It's just the plain name BTW: test_set.wolandscat wrote:In the transformation scenario, I added a variable 'test_set' and a value for it. (It's not clear whether it should be 'test_set', '{test_set}', '$test_set', '${test_set}' or something else).
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 5
- Joined: Thu Oct 03, 2013 1:37 am
Re: Passing directory parameter to Xquery from Trans Scenari
Post by wolandscat »
Yes, I discovered that does happen, and seems to work when you follow the Oxygen proper workflow. It wasn't that obvious initially, because there is a lot on the screen in Oxygen. I'm still not completely sure I understand how Oxygen 'knows' when there really is a binding between a given Xquery and its one or more transformation scenarios. But executing them does now seem to work as I would expect.
thanks for the input.
- thomas
thanks for the input.
- thomas
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service