Hi, simple problem here: importing a number of documents using information studio. I'd like to add a number of collection to each imported document. while the code seems to be correct (see below, copied and pasted directly from the text box in info studio), and all documents are loaded just fine, the collections aren't attached to the documents.
please note this is the first time I'm using cpf so I probably haven't grasped all the concepts correctly. thanks in advance, cheers, Jakob. xquery version "1.0-ml"; (: Copyright 2002-2010 MarkLogic Corporation. All Rights Reserved. :) (: :: Custom action. It must be a CPF action module. :: Replace this text completely, or use it as a template and :: add imports, declarations, :: and code between START and END comment tags. :: Uses the external variables: :: $cpf:document-uri: The document being processed :: $cpf:transition: The transition being executed :) import module namespace cpf = "http://marklogic.com/cpf" at "/MarkLogic/cpf/cpf.xqy"; (: START custom imports and declarations; imports must be in Modules :) (: END custom imports and declarations :) declare option xdmp:mapping "false"; declare variable $cpf:document-uri as xs:string external; declare variable $cpf:transition as node() external; if ( cpf:check-transition($cpf:document-uri,$cpf:transition)) then try { (: START your custom XQuery here :) let $dateTime := document($cpf:document-uri)/Item/ExportDate let $year-collection := string(year-from-dateTime($dateTime)) let $month-collection := concat($year-collection, '-', month-from-dateTime($dateTime)) let $day-collection := concat($month-collection, '-', day-from-dateTime($dateTime)) return xdmp:document-add-collections( $cpf:document-uri, ($year-collection, $month-collection, $day-collection) ) (: END your custom XQuery here :) , cpf:success( $cpf:document-uri, $cpf:transition, () ) } catch ($e) { cpf:failure( $cpf:document-uri, $cpf:transition, $e, () ) } else () _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
