From: Alister P. <gsp...@gm...> - 2014-07-23 22:29:49
|
I’ve added a zip:update function to my clone of the expath zip module. (I desperately need this function in eXist 2.x - to replace a module I wrote for 1.2 and 1.4) https://github.com/gspringtech/exist (There’s also a minimal zip:entries function - not so useful considering what’s available in the compression: module.) zip:update( $href as xs:anyURI, $paths as xs:string+, $binaries as xs:base64Binary+ ) as xs:base64Binary? The function will replace existing content or add new content to a zip file. This is not the same as the specified zip:update-entries() - which would be difficult to use as well as hard to code. I’ve chosen an href for the source file - so that it can be processed as a stream - but couldn’t quite figure out how to do the same for the binaries. In my use case, the updated content would be generated and not stored. Example: xquery version “1.0"; let $odt := '/db/Job-Listing.odt' let $content := '/db/new-content.xml' let $binary-content := util:string-to-binary(util:serialize(doc($content),"method=xml")) let $test-binary:= util:string-to-binary(util:serialize(<doc>Something else</doc>,"method=xml”)) let $updated := zip:update(xs:anyURI($odt),("content.xml","test/test.xml"), ($binary-content, $test-binary )) return xmldb:store("/db","updated.odt",$updated) I haven’t written zip:zip-file (which creates a new Zip file) because that functionality already exists in the compression module. I guess that the way forward is to follow the new EXPath Archive spec. Regards, Alister. |