Hi guys,

Just wanted to know if the issue in below thread has ever been fixed.

http://web.archiveorange.com/archive/v/uRmkWnxszXP6g7Xuw33H

To shortly describe the use case:

http://cocoon.apache.org/2.1/userdocs/ziparchive-serializer.html

The zipserializer only allows either:

-          You specify a @src  pointing to some cocoon pipeline using cocoon:// 
  (Ideally it would also support the servlet: protocol as now I have to provide 
a façade in the calling cocoon block)

-          You specify inline content and the @serializer

In a ideal world you should be able to use @src in combination with the 
@serializer because now I have to first include the content from a pipeline by 
using <cinclude> before calling
<map:serialize type="zip"/>



I actually created some nice generic functionality to work around some issues:


************************ FLOWSCRIPT ***************************************
function downloadImdsZip() {
    var entries = [];
    new 
Collection(cocoon.request.getParameterValues("id")).forEach(function(id){
                var entry = {"name": id + ".xml", "source": 
"cocoon://chemicalcontent/imds/" + id + ".xml", "serializer": "upload"};
                print('Adding entry [name=' + entry.name + ', source=' + 
entry.source + '] to ZIP archive.');
                entries.push(entry);
    });
    var response = cocoon.response;
                response.setHeader(
                    "Content-Disposition",
                    "attachment; filename=imds.zip"
                );
    cocoon.sendPage("zipArchive", {"entries": entries});
}

*************************************************************************
<?xml version="1.0" encoding="UTF-8"?>
<jx:template
  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0";
  xmlns:zip="http://apache.org/cocoon/zip-archive/1.0";
  xmlns:cinclude="http://apache.org/cocoon/include/1.0";>
  <!--
   This jx expects an array called 'entries' containing objects with following 
properties:
   * name       (mandatory)
   * source     (mandatory)
   * serializer (optional)
   *
   * If both source and serializer are provided, we assume that we want to 
include the content inline so we can specify the serializer
   -->
  <zip:archive>
    <jx:forEach var="entry" items="${entries}">
      <zip:entry name="${entry.name}">
        <jx:choose>
          <jx:when test="${entry.serializer != null}">
            <jx:attribute name="serializer" value="${entry.serializer}"/>
            <cinclude:include src="${entry.source}"/>
          </jx:when>
          <jx:otherwise>
            <jx:attribute name="src" value="${entry.source}"/>
          </jx:otherwise>
        </jx:choose>
      </zip:entry>
    </jx:forEach>
  </zip:archive>
</jx:template>
*************************************************************************
<map:match pattern="zipArchive">
  <map:generate src="jx/zipArchive.jx" type="jx"/>
  <map:transform type="cinclude"/>
  <map:serialize type="zip"/>
</map:match>
*************************************************************************

But I now am facing the same nullpointer exception as in the link above.

Anyone some usefull input on this matter?

Cheers,
Robby Pelssers

Reply via email to