Menu

collections

apb2006
2009-05-27
2013-06-05
  • apb2006

    apb2006 - 2009-05-27

    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

     
    • Peter M. Fischer

      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

       
    • apb2006

      apb2006 - 2009-05-28

      Thanks Peter, that works for me. /Andy

       

Log in to post a comment.

Auth0 Logo