Hi,
I am trying to use MXquery to update multiple files in a directory. Is there a way to specify a collection as the contents of a folder?
---------mx.bat----------
REM run mxquery
java -jar "C:/Program Files/mxquery-bin/dist/mxquery.jar" -um -x -c static-collections=file:/C:/Temp/ -f coll.xq
---------coll.xq---------
collection("file:/C:/Temp/")
---------------
mx coll.xq
The error is
MXQuery 0.6.0
Error occured during evaluation:
Error code: err:FODC0004
Error message: Collection for URI file:/C:/Temp/ not set
How can I do this?
Thanks /Andy
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
similar functionality exists in MXQuery, but the documentation is currently somewhat lacking:
There are two non-standard, builtin functions
- mxq:subFiles($baseDir as xs:string, $pattern as xs:string) as xs:string*
- mxq:subFiles($baseDir as xs:string, $pattern as xs:string, $recDepth) as xs:string*
These functions will generate the list of file Names in $baseDir, matching the pattern given in $pattern. The first will also list the files in all subdirectories, the second also to restrict the depth (e.g. just on level down) by giving $recDepth.
In your case, the following should work
for $f in mxq:subFiles('C:/Temp/','',1) return $f
Regards,
Peter
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am trying to use MXquery to update multiple files in a directory. Is there a way to specify a collection as the contents of a folder?
---------mx.bat----------
REM run mxquery
java -jar "C:/Program Files/mxquery-bin/dist/mxquery.jar" -um -x -c static-collections=file:/C:/Temp/ -f coll.xq
---------coll.xq---------
collection("file:/C:/Temp/")
---------------
mx coll.xq
The error is
MXQuery 0.6.0
Error occured during evaluation:
Error code: err:FODC0004
Error message: Collection for URI file:/C:/Temp/ not set
How can I do this?
Thanks /Andy
Dear Andy,
similar functionality exists in MXQuery, but the documentation is currently somewhat lacking:
There are two non-standard, builtin functions
- mxq:subFiles($baseDir as xs:string, $pattern as xs:string) as xs:string*
- mxq:subFiles($baseDir as xs:string, $pattern as xs:string, $recDepth) as xs:string*
These functions will generate the list of file Names in $baseDir, matching the pattern given in $pattern. The first will also list the files in all subdirectories, the second also to restrict the depth (e.g. just on level down) by giving $recDepth.
In your case, the following should work
for $f in mxq:subFiles('C:/Temp/','',1) return $f
Regards,
Peter
Thanks Peter, that works for me. /Andy