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

List:       xml-cocoon-users
Subject:    RE: [C2.2] Get Element from uploaded file
From:       Robby Pelssers <Robby.Pelssers () nxp ! com>
Date:       2011-11-18 9:29:08
Message-ID: 78B923726E7D59429936580CF127E943A1EC7A728C () eu1rdcrdc1wx032 ! exi ! nxp ! com
[Download RAW message or body]

I just published a little write-up about a similar use case as you described on \
http://robbypelssers.blogspot.com/2011/11/apache-cocoon-from-xml-to-json-as.html

Kind regards,
Robby


From: Matthias Müller [mailto:pymote@yahoo.de]
Sent: Friday, November 18, 2011 8:34 AM
To: users@cocoon.apache.org
Subject: Re: [C2.2] Get Element from uploaded file

I extended your first approach:

in the flow script I use the inputStream from the uploaded file to feed a \
XpathEvaluator class in combination with the an xpath expression.

var inputStream = widget.getValue().getInputStream();
var xpath = "/my/path/to/element";
var result = cocoon.getComponent('XPathEvaluator').evaluate(inputStream, xpath);

Thanks again, Matthias


________________________________
Von: Robby Pelssers <Robby.Pelssers@nxp.com>
An: Matthias Müller <pymote@yahoo.de>; "users@cocoon.apache.org" \
                <users@cocoon.apache.org>
Gesendet: 16:22 Donnerstag, 17.November 2011
Betreff: RE: [C2.2] Get Element from uploaded file
I actually had a similar need the other week and while I have used some XML-JAVA \
mappers like Castor and XStream in the past I decided to try another approach where I \
generated JSON which can be used from flowscript:


/** flowscript function to generate the pdf **/


function json2Object(json) {
                return eval("(" + json + ")");
}


function generatePDF() {
    var id = cocoon.parameters.id;  //e.g. PH3330L


    //var fileName = cocoon.getComponent('fileNameExtractor').getFileName(id);

    var output = new Packages.java.io.ByteArrayOutputStream();

    var uri = "extractData/" + id;
    //now we invoke a pipeline which returns a JSON string. E.g:
    /**
     *   {"id": "PH3330L","fileName": "PH3330L.pdf"},
     */
    cocoon.processPipelineTo(uri, null, output);

    var responseData = json2Object(output.toString());


    var response = cocoon.response;
    response.setHeader(
                "Content-Disposition",
                "attachment; filename=" + responseData.fileName;
    );
    cocoon.sendPage('source2pdf/' + id);

}


Sitemap:
----------
<!--
  {1} id: unique identifier for the source xml used to generate the PDF
-->
<map:match pattern="generatePdf/*">
  <map:call function="generatePDF">
    <map:parameter name="id" value="{1}"/>
  </map:call>
</map:match>

<map:match pattern="source2pdf/*">
  <map:generate src="source/{1}.xml"/> <!-- assume our sources are located in source \
folder -->  <map:transform src="xslt/source2poi.xslt"/>
  <map:serialize type="pdf"/>
</map:match>

<!--
  {1} id: unique identifier for the source xml used to generate the PDF
-->
<map:match pattern="extractData/*">
  <map:generate src="source/{1}.xml"/>
  <map:transform src="extractData.xslt"/>
  <map:serialize type="json"/>  <!-- you can quickly test with @type="text" -->
</map:match>



/**** ExtractData.xslt will generate a JSON representation of the DATA needed ****/

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Author: Robby Pelssers
-->

<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xsl:output method="text" version="1.0" encoding="UTF-8"/>


  <xsl:template match="/">
    <xsl:text>{"id": "</xsl:text><xsl:value-of select="someXpathExpr"/><xsl:text>", \
"fileName: "</xsl:text><xsl:value-of select="someXpathExpr"/>"}<xsl:text></xsl:text>  \
</xsl:template>



</xsl:stylesheet>


[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:x="urn:schemas-microsoft-com:office:excel" \
xmlns:p="urn:schemas-microsoft-com:office:powerpoint" \
xmlns:a="urn:schemas-microsoft-com:office:access" \
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" \
xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" \
xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" \
xmlns:b="urn:schemas-microsoft-com:office:publisher" \
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" \
xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" \
xmlns:odc="urn:schemas-microsoft-com:office:odc" \
xmlns:oa="urn:schemas-microsoft-com:office:activation" \
xmlns:html="http://www.w3.org/TR/REC-html40" \
xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" \
xmlns:rtc="http://microsoft.com/officenet/conferencing" xmlns:D="DAV:" \
xmlns:Repl="http://schemas.microsoft.com/repl/" \
xmlns:mt="http://schemas.microsoft.com/sharepoint/soap/meetings/" \
xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" \
xmlns:ppda="http://www.passport.com/NameSpace.xsd" \
xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" \
xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" \
xmlns:ds="http://www.w3.org/2000/09/xmldsig#" \
xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" \
xmlns:udc="http://schemas.microsoft.com/data/udc" \
xmlns:xsd="http://www.w3.org/2001/XMLSchema" \
xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" \
xmlns:ec="http://www.w3.org/2001/04/xmlenc#" \
xmlns:sp="http://schemas.microsoft.com/sharepoint/" \
xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" \
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
xmlns:udcs="http://schemas.microsoft.com/data/udc/soap" \
xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" \
xmlns:udcp2p="http://schemas.microsoft.com/data/udc/parttopart" \
xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" \
xmlns:dsss="http://schemas.microsoft.com/office/2006/digsig-setup" \
xmlns:dssi="http://schemas.microsoft.com/office/2006/digsig" \
xmlns:mdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" \
xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" \
xmlns:spwp="http://microsoft.com/sharepoint/webpartpages" \
xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" \
xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" \
xmlns:pptsl="http://schemas.microsoft.com/sharepoint/soap/SlideLibrary/" \
xmlns:spsl="http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService" \
xmlns:Z="urn:schemas-microsoft-com:" xmlns:st="&#1;" \
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)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);} o\:* \
{behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@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:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 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:12.0pt;
	font-family:"Times New Roman","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.yiv432007957msonormal, li.yiv432007957msonormal, div.yiv432007957msonormal
	{mso-style-name:yiv432007957msonormal;
	mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
p.yiv432007957msochpdefault, li.yiv432007957msochpdefault, \
div.yiv432007957msochpdefault  {mso-style-name:yiv432007957msochpdefault;
	mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
p.yiv432007957msonormal1, li.yiv432007957msonormal1, div.yiv432007957msonormal1
	{mso-style-name:yiv432007957msonormal1;
	mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
p.yiv432007957msochpdefault1, li.yiv432007957msochpdefault1, \
div.yiv432007957msochpdefault1  {mso-style-name:yiv432007957msochpdefault1;
	mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
span.yiv432007957msohyperlink
	{mso-style-name:yiv432007957msohyperlink;}
span.yiv432007957msohyperlinkfollowed
	{mso-style-name:yiv432007957msohyperlinkfollowed;}
span.yiv432007957msohyperlink1
	{mso-style-name:yiv432007957msohyperlink1;}
span.yiv432007957msohyperlinkfollowed1
	{mso-style-name:yiv432007957msohyperlinkfollowed1;}
span.yiv432007957emailstyle171
	{mso-style-name:yiv432007957emailstyle171;}
span.yiv432007957emailstyle27
	{mso-style-name:yiv432007957emailstyle27;}
p.yiv432007957msonormal2, li.yiv432007957msonormal2, div.yiv432007957msonormal2
	{mso-style-name:yiv432007957msonormal2;
	margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
span.yiv432007957msohyperlink2
	{mso-style-name:yiv432007957msohyperlink2;
	color:blue;
	text-decoration:underline;}
span.yiv432007957msohyperlinkfollowed2
	{mso-style-name:yiv432007957msohyperlinkfollowed2;
	color:purple;
	text-decoration:underline;}
p.yiv432007957msonormal3, li.yiv432007957msonormal3, div.yiv432007957msonormal3
	{mso-style-name:yiv432007957msonormal3;
	mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
p.yiv432007957msochpdefault2, li.yiv432007957msochpdefault2, \
div.yiv432007957msochpdefault2  {mso-style-name:yiv432007957msochpdefault2;
	mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
p.yiv432007957msonormal11, li.yiv432007957msonormal11, div.yiv432007957msonormal11
	{mso-style-name:yiv432007957msonormal11;
	margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
span.yiv432007957msohyperlink11
	{mso-style-name:yiv432007957msohyperlink11;
	color:blue;
	text-decoration:underline;}
span.yiv432007957msohyperlinkfollowed11
	{mso-style-name:yiv432007957msohyperlinkfollowed11;
	color:purple;
	text-decoration:underline;}
span.yiv432007957emailstyle1711
	{mso-style-name:yiv432007957emailstyle1711;
	font-family:"Arial","sans-serif";
	color:#1F497D;}
p.yiv432007957msochpdefault11, li.yiv432007957msochpdefault11, \
div.yiv432007957msochpdefault11  {mso-style-name:yiv432007957msochpdefault11;
	mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	font-size:10.0pt;
	font-family:"Times New Roman","serif";}
span.yiv432007957emailstyle271
	{mso-style-name:yiv432007957emailstyle271;
	font-family:"Arial","sans-serif";
	color:#1F497D;}
span.EmailStyle38
	{mso-style-type:personal-reply;
	font-family:"Calibri","sans-serif";
	color:#1F497D;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></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 \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I just \
published a little write-up about a similar use case as you described on <a \
href="http://robbypelssers.blogspot.com/2011/11/apache-cocoon-from-xml-to-json-as.html \
">http://robbypelssers.blogspot.com/2011/11/apache-cocoon-from-xml-to-json-as.html</a><o:p></o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Kind \
regards,<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Robby<o:p></o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div><div \
style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p \
class=MsoNormal><b><span \
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span \
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Matthias Müller \
[mailto:pymote@yahoo.de] <br><b>Sent:</b> Friday, November 18, 2011 8:34 \
AM<br><b>To:</b> users@cocoon.apache.org<br><b>Subject:</b> Re: [C2.2] Get Element \
from uploaded file<o:p></o:p></span></p></div></div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:black'>I extended your \
first approach:<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:black'><o:p>&nbsp;</o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:black'>in the flow \
script I use the inputStream from the uploaded file to feed a XpathEvaluator class in \
combination with the an xpath expression.<o:p></o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:black'><o:p>&nbsp;</o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:black'>var inputStream \
= widget.getValue().getInputStream();<br>var xpath = \
&quot;/my/path/to/element&quot;;<br>var result = \
cocoon.getComponent('XPathEvaluator').evaluate(inputStream, \
xpath);<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:black'><o:p>&nbsp;</o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:black'>Thanks again, \
Matthias<o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:black'><o:p>&nbsp;</o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:black'><o:p>&nbsp;</o:p></span></p></div><div><div><div \
class=MsoNormal align=center style='text-align:center;background:white'><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:black'><hr size=1 \
width="100%" align=center></span></div><p class=MsoNormal \
style='margin-bottom:12.0pt;background:white'><b><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:black'>Von:</span></b><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:black'> Robby Pelssers \
&lt;Robby.Pelssers@nxp.com&gt;<br><b>An:</b> Matthias Müller &lt;pymote@yahoo.de&gt;; \
&quot;users@cocoon.apache.org&quot; &lt;users@cocoon.apache.org&gt; \
<br><b>Gesendet:</b> 16:22 Donnerstag, 17.November 2011<br><b>Betreff:</b> RE: [C2.2] \
Get Element from uploaded file</span><span \
style='color:black'><o:p></o:p></span></p><div \
id=yiv432007957><div><div><div><div><div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>I actually \
had a similar need the other week and while I have used some XML-JAVA mappers like \
Castor and XStream in the past I decided to try another approach where I generated \
JSON which can be used from flowscript:</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>/** \
flowscript function to generate the pdf **/</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>function \
json2Object(json) {</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
return eval(&quot;(&quot; + json + &quot;)&quot;);</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>}</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>function \
generatePDF() {</span><span style='color:black'><o:p></o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp; \
var id = cocoon.parameters.id;&nbsp; //e.g. PH3330L</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp; \
//var fileName = cocoon.getComponent('fileNameExtractor').getFileName(id);</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp; \
var output = new Packages.java.io.ByteArrayOutputStream();</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp; \
var uri = &quot;extractData/&quot; + id;&nbsp;&nbsp; </span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;//now \
we invoke a pipeline which returns a JSON string. E.g:</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp; \
/**</span><span style='color:black'><o:p></o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp; \
*&nbsp;&nbsp; {&quot;id&quot;: &quot;PH3330L&quot;,&quot;fileName&quot;: \
&quot;PH3330L.pdf&quot;},</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp; \
*/</span><span style='color:black'><o:p></o:p></span></p></div><div><p \
class=MsoNormal style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp; \
cocoon.processPipelineTo(uri, null, output);</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp; \
var responseData = json2Object(output.toString());&nbsp;&nbsp;&nbsp; </span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp; \
var response = cocoon.response;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& \
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span><span style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp; \
response.setHeader(</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&quot;Content-Disposition&quot;,</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&quot;attachment; filename=&quot; + responseData.fileName;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp; \
);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp; \
cocoon.sendPage('source2pdf/' + id);</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>}</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \
style='font-size:11.0pt;font-family:"Arial","sans-serif";color:#1F497D'>&nbsp;</span><span \
style='color:black'><o:p></o:p></span></p></div><div><p class=MsoNormal \
style='background:white'><span \



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

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