From: Alister P. <gsp...@gm...> - 2014-07-24 03:16:25
|
Hi Joe, I will submit a pull request, but I’m concerned because my additions don’t match the spec. This zip:update function matches my own use-case - replacing one file in a zip, where the zip is stored in the database and the content is possibly in-memory. On 24 Jul 2014, at 11:02 am, Joe Wicentowski <jo...@gm...> wrote: > Alister, > > Great! Have you considered submitting your work as a pull request? > > Joe > > Sent from my iPhone > >> On Jul 23, 2014, at 6:29 PM, Alister Pillow <gsp...@gm...> wrote: >> >> 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. >> >> >> ------------------------------------------------------------------------------ >> Want fast and easy access to all the code in your enterprise? Index and >> search up to 200,000 lines of code with a free copy of Black Duck >> Code Sight - the same software that powers the world's largest code >> search on Ohloh, the Black Duck Open Hub! Try it now. >> http://p.sf.net/sfu/bds >> _______________________________________________ >> Exist-development mailing list >> Exi...@li... >> https://lists.sourceforge.net/lists/listinfo/exist-development |