document retrieval for at4am

5 views
Skip to first unread message

Ashok Hariharan

unread,
Feb 18, 2013, 8:45:43 AM2/18/13
to bungen...@googlegroups.com
The service needs to get attachments matching the below criteria :

xquery version "3.0";

declare namespace bu="http://portal.bungeni.org/1.0/";

let $coll := collection('/db/bungeni-xml')/bu:ontology
        [@for='document']
        [
          bu:document[bu:docType[bu:value[. = 'Bill']]]
           [bu:status[bu:value[. = 'received']]]
        ]
        /bu:attachments/bu:attachment[bu:type[bu:value[. = 'main-xml']]]
return $coll

To get data to work with --
You can input Bill documents in Bungeni (as a clerk), and akmoantoso bills to it as attachments (from examples.akomantoso.org ) after that send the bill to the recieved state.
At this point there should be documents in eXist matching the criteria ..

Then you will have to use an adaptation of this api in your service to get the actual akomatnoso attachment out in eXist ..

declare function bun:get-attachment($acl as xs:string, $uri as xs:string, $attid as xs:integer) {
   
    (: get the document through acl as validation :)
    let $acl-permissions := cmn:get-acl-permissions($acl)
    let $att-acl := bun:documentitem-full-acl($acl, $uri)  

    (: get the attachment with the given file id :)
    for $attachedfile in $att-acl/bu:attachments/bu:attachment
    return
        if($attachedfile/bu:attachmentId cast as xs:integer eq $attid) then (
            response:stream-binary(
                util:binary-doc(concat(cmn:get-att-db(),'/',$attachedfile/bu:fileHash)) cast as xs:base64Binary,
                $attachedfile/bu:mimetype/bu:value,
                $attachedfile/bu:name),
            response:set-header("Content-Disposition" , concat("attachment; filename=",  $attachedfile/bu:name)),
            <xml/>
        )
        else ()
};

Reply all
Reply to author
Forward
0 new messages