Loading TOC...

infodev:filesystem-walk

infodev:filesystem-walk(
   $dir-path as xs:string,
   $ticket-id as xs:string,
   $function as xdmp:function,
   $policy-deltas as element(info:options)?,
   [$context as item()?]
) as empty-sequence()

Summary

[DEPRECATED] This function can be used along with the infodev:ingest function to build custom load operations.

This function recurses the specified filesystem directory and uses the policy deltas from the specified ticket to determine which files to select for ingestion. The specified process function can be written to modify the content of files before calling the infodev:ingest function to load them into the database.

Parameters
dir-path The directory path to walk.
ticket-id The ID of the created ticket.
function The process function to apply to each file. This is where you can make modifications to each file before loading them into the database. The function signature must be as follows:
     declare function my:function(
        $document as node()?,
        $source-location as xs:string,
        $ticket-id as xs:string,
        $policy-deltas as element(info:options)?,
        $context as item()?)
     as empty-sequence()
     
policy-deltas One or more deltas to be applied to the policy.
context User-supplied context that is passed to the process function.

Example

   xquery version "1.0-ml"; 

   import module namespace info = "http://marklogic.com/appservices/infostudio"  
      at "/MarkLogic/appservices/infostudio/info.xqy"; 
   import module namespace infodev = "http://marklogic.com/appservices/infostudio/dev"
      at "/MarkLogic/appservices/infostudio/infodev.xqy";

   declare function local:process-file(
       $document as node()?,
       $source-location as xs:string,
       $ticket-id as xs:string,
       $policy-deltas as element(info:options)?,
       $context as item()?)
     {
       (: You can modify the file here :)
       infodev:ingest($document, $source-location, $ticket-id)
     };

   let $function := xdmp:function(xs:QName("local:process-file"))
   let $annotation := <info:annotation>Loading XML docs</info:annotation>
   let $dir-path := "C:\mydocs\xmldocs"
   let $ticket := infodev:ticket-create(
                      $annotation,
                      "myDB",
                      (),
                      () ) 

   return infodev:filesystem-walk(
                      $dir-path,
                      $ticket,
	              $function,
	              (),
                      () )

  (: This query does the same thing as the info:load function.  You can write the 
     process-file function to modify each file in some manner before calling
     the infodev:ingest function. :)
    

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.