Note the first invocation of ddtek:serialize-to-url() includes the auto-create=yes option, making sure a new ZIP file is created. The following two invocations are adding more documents to the ZIP. The zip URL consists basically out of two parts. First the location of the ZIP file is specified. And second, after the exclamation mark, the location where the file needs to be added in the ZIP file.

Executing the above XQuery, results in a ZIP file as follows.

Let's now have a look at a more concrete example. In Create (EDI) messages out of your database we explained how easy it is to create EDI messages based on your data in a relational database. But assume now each of these EDI messages should be compressed in a ZIP file. Not much is changed compared to what we know already.

The next example creates for each supplier with orders for today, a ZIP file named after the supplier. Each of the ZIP files contain a single EANCOM ORDERS message. Note that only the "let $url" clause is specific to the creation of the ZIP files.

Back to our question, "Why would you want to create ZIP files in XQuery?".Yes there is more than the type of use cases shown above. Remember a rather old post XQuery your office documents. Both Office Open XML and OpenDocument Format are based on the ZIP standard. The ability to create ZIP files with DataDirect XQuery, opens the world of creating office documents. In my next post I'll show how to create Microsoft Excel spreadsheets in a few lines of XQuery. Followed with demonstrating the equivalent for OpenOffice.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.