[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xml-cocoon-users
Subject:    Nullpointer in ZipSerializer (cocoon 2.2)
From:       Robby Pelssers <Robby.Pelssers () nxp ! com>
Date:       2011-11-10 12:52:05
Message-ID: 78B923726E7D59429936580CF127E943A192CD2E62 () eu1rdcrdc1wx032 ! exi ! nxp ! com
[Download RAW message or body]

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


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type \
content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word \
12 (filtered medium)"><style><!-- /* Font Definitions */
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:PMingLiU;
	panose-1:2 2 5 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:"\@PMingLiU";
	panose-1:2 2 5 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{mso-style-priority:34;
	margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:.5in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
/* List Definitions */
@list l0
	{mso-list-id:1707949687;
	mso-list-type:hybrid;
	mso-list-template-ids:1649867596 1663360226 67698691 67698693 67698689 67698691 \
67698693 67698689 67698691 67698693;} @list l0:level1
	{mso-level-start-at:0;
	mso-level-number-format:bullet;
	mso-level-text:-;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Calibri","sans-serif";
	mso-fareast-font-family:PMingLiU;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div \
class=WordSection1><p class=MsoNormal><span lang=NL>Hi guys,<o:p></o:p></span></p><p \
class=MsoNormal><span lang=NL><o:p>&nbsp;</o:p></span></p><p class=MsoNormal>Just \
wanted to know if the issue in below thread has ever been fixed.  <o:p></o:p></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><a \
href="http://web.archiveorange.com/archive/v/uRmkWnxszXP6g7Xuw33H">http://web.archiveorange.com/archive/v/uRmkWnxszXP6g7Xuw33H</a><o:p></o:p></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>To shortly describe the use \
case:<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><a \
href="http://cocoon.apache.org/2.1/userdocs/ziparchive-serializer.html">http://cocoon.apache.org/2.1/userdocs/ziparchive-serializer.html</a><o:p></o:p></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>The zipserializer only allows \
either:<o:p></o:p></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 \
level1 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>-<span \
style='font:7.0pt "Times New \
Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span></span><![endif]>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)<o:p></o:p></p><p class=MsoListParagraph \
style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span \
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New \
Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span></span><![endif]>You specify inline content and the \
@serializer<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p \
class=MsoNormal>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 &lt;cinclude&gt; before calling <o:p></o:p></p><p \
class=MsoNormal>&lt;map:serialize type=&#8221;zip&#8221;/&gt;<o:p></o:p></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>I actually created some nice \
generic functionality to work around some issues:<o:p></o:p></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p \
class=MsoNormal>************************ FLOWSCRIPT \
***************************************<o:p></o:p></p><p class=MsoNormal>function \
downloadImdsZip() {<o:p></o:p></p><p class=MsoNormal>    var entries = \
[];<o:p></o:p></p><p class=MsoNormal>    new \
Collection(cocoon.request.getParameterValues(&quot;id&quot;)).forEach(function(id){<o:p></o:p></p><p \
class=MsoNormal>                var entry = {&quot;name&quot;: id + &quot;.xml&quot;, \
&quot;source&quot;: &quot;cocoon://chemicalcontent/imds/&quot; + id + \
&quot;.xml&quot;, &quot;serializer&quot;: &quot;upload&quot;};<o:p></o:p></p><p \
class=MsoNormal>                print('Adding entry [name=' + entry.name + ', \
source=' + entry.source + '] to ZIP archive.');          <o:p></o:p></p><p \
class=MsoNormal>                entries.push(entry);<o:p></o:p></p><p \
class=MsoNormal>    });<o:p></o:p></p><p class=MsoNormal>    var response = \
cocoon.response;                         <o:p></o:p></p><p class=MsoNormal>           \
response.setHeader(<o:p></o:p></p><p class=MsoNormal>                    <span \
lang=FR>&quot;Content-Disposition&quot;,<o:p></o:p></span></p><p \
class=MsoNormal><span lang=FR>                    &quot;attachment; \
filename=imds.zip&quot;<o:p></o:p></span></p><p class=MsoNormal><span lang=FR>        \
</span>);    <o:p></o:p></p><p class=MsoNormal>    \
cocoon.sendPage(&quot;zipArchive&quot;, {&quot;entries&quot;: entries});  \
<o:p></o:p></p><p class=MsoNormal>}<o:p></o:p></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p \
class=MsoNormal>*************************************************************************<o:p></o:p></p><p \
class=MsoNormal>&lt;?xml version=&quot;1.0&quot; \
encoding=&quot;UTF-8&quot;?&gt;<o:p></o:p></p><p class=MsoNormal>&lt;jx:template \
<o:p></o:p></p><p class=MsoNormal>  \
xmlns:jx=&quot;http://apache.org/cocoon/templates/jx/1.0&quot;<o:p></o:p></p><p \
class=MsoNormal>  xmlns:zip=&quot;http://apache.org/cocoon/zip-archive/1.0&quot;<o:p></o:p></p><p \
class=MsoNormal>  xmlns:cinclude=&quot;http://apache.org/cocoon/include/1.0&quot;&gt;<o:p></o:p></p><p \
class=MsoNormal>  &lt;!-- <o:p></o:p></p><p class=MsoNormal>   This jx expects an \
array called 'entries' containing objects with following properties:<o:p></o:p></p><p \
class=MsoNormal>   * name       (mandatory)<o:p></o:p></p><p class=MsoNormal>   * \
source     (mandatory)<o:p></o:p></p><p class=MsoNormal>   * serializer \
(optional)<o:p></o:p></p><p class=MsoNormal>   * <o:p></o:p></p><p class=MsoNormal>   \
* If both source and serializer are provided, we assume that we want to include the \
content inline so we can specify the serializer<o:p></o:p></p><p class=MsoNormal>   \
--&gt;<o:p></o:p></p><p class=MsoNormal>  &lt;zip:archive&gt;<o:p></o:p></p><p \
class=MsoNormal>    &lt;jx:forEach var=&quot;entry&quot; \
items=&quot;${entries}&quot;&gt;<o:p></o:p></p><p class=MsoNormal>      &lt;zip:entry \
name=&quot;${entry.name}&quot;&gt;<o:p></o:p></p><p class=MsoNormal>        \
&lt;jx:choose&gt;<o:p></o:p></p><p class=MsoNormal>          &lt;jx:when \
test=&quot;${entry.serializer != null}&quot;&gt;<o:p></o:p></p><p class=MsoNormal>    \
&lt;jx:attribute name=&quot;serializer&quot; \
value=&quot;${entry.serializer}&quot;/&gt; <o:p></o:p></p><p class=MsoNormal>         \
&lt;cinclude:include src=&quot;${entry.source}&quot;/&gt;          <o:p></o:p></p><p \
class=MsoNormal>          &lt;/jx:when&gt;<o:p></o:p></p><p class=MsoNormal>          \
&lt;jx:otherwise&gt;<o:p></o:p></p><p class=MsoNormal>            &lt;jx:attribute \
name=&quot;src&quot; value=&quot;${entry.source}&quot;/&gt;           \
<o:p></o:p></p><p class=MsoNormal>          &lt;/jx:otherwise&gt;<o:p></o:p></p><p \
class=MsoNormal>        &lt;/jx:choose&gt;<o:p></o:p></p><p class=MsoNormal>      \
&lt;/zip:entry&gt;<o:p></o:p></p><p class=MsoNormal>    \
&lt;/jx:forEach&gt;<o:p></o:p></p><p class=MsoNormal>  \
&lt;/zip:archive&gt;<o:p></o:p></p><p \
class=MsoNormal>&lt;/jx:template&gt;<o:p></o:p></p><p \
class=MsoNormal>*************************************************************************<o:p></o:p></p><p \
class=MsoNormal style='text-autospace:none'><span \
style='font-size:10.0pt;font-family:"Courier New";color:black'>&lt;map:match \
pattern=&quot;zipArchive&quot;&gt;<o:p></o:p></span></p><p class=MsoNormal \
style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier \
New";color:black'>  &lt;map:generate src=&quot;jx/zipArchive.jx&quot; \
type=&quot;jx&quot;/&gt;<o:p></o:p></span></p><p class=MsoNormal \
style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier \
New";color:black'>  &lt;map:transform \
type=&quot;cinclude&quot;/&gt;<o:p></o:p></span></p><p class=MsoNormal \
style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier \
New";color:black'>  &lt;map:serialize \
type=&quot;zip&quot;/&gt;<o:p></o:p></span></p><p class=MsoNormal \
style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier \
New";color:black'>&lt;/map:match&gt;<o:p></o:p></span></p><p \
class=MsoNormal>*************************************************************************<o:p></o:p></p><p \
class=MsoNormal style='text-autospace:none'><span \
style='font-size:10.0pt;font-family:"Courier \
New";color:black'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal \
style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier \
New";color:black'>But I now am facing the same nullpointer exception as in the link \
above.<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span \
style='font-size:10.0pt;font-family:"Courier \
New";color:black'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal \
style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier \
New";color:black'>Anyone some usefull input on this matter?<o:p></o:p></span></p><p \
class=MsoNormal style='text-autospace:none'><span \
style='font-size:10.0pt;font-family:"Courier \
New";color:black'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal \
style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier \
New";color:black'>Cheers,<o:p></o:p></span></p><p class=MsoNormal \
style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier \
New";color:black'>Robby Pelssers<o:p></o:p></span></p><p class=MsoNormal \
style='text-autospace:none'><o:p>&nbsp;</o:p></p></div></body></html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic