Return-Path: X-Original-To: apmail-cocoon-users-archive@www.apache.org Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 467A97BC8 for ; Thu, 17 Nov 2011 14:05:20 +0000 (UTC) Received: (qmail 73635 invoked by uid 500); 17 Nov 2011 14:05:19 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 73597 invoked by uid 500); 17 Nov 2011 14:05:19 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: users@cocoon.apache.org List-Id: Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 73590 invoked by uid 99); 17 Nov 2011 14:05:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Nov 2011 14:05:19 +0000 X-ASF-Spam-Status: No, hits=-0.1 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [57.67.164.70] (HELO be1ssnxpe2.nxp.com) (57.67.164.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Nov 2011 14:05:09 +0000 Received: from EU1RDCRDC1VW024.exi.nxp.com ([134.27.176.169]) by be1ssnxpe2.nxp.com (8.14.4/8.14.4) with ESMTP id pAHE4X84014603 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT); Thu, 17 Nov 2011 15:04:48 +0100 Received: from eu1rdcrdc1wx032.exi.nxp.com ([134.27.179.186]) by EU1RDCRDC1VW024.exi.nxp.com ([134.27.176.169]) with mapi; Thu, 17 Nov 2011 15:04:33 +0100 From: Robby Pelssers To: "users@cocoon.apache.org" , =?iso-8859-1?Q?Matthias_M=FCller?= Date: Thu, 17 Nov 2011 15:04:31 +0100 Subject: RE: [C2.2] Get Element from uploaded file Thread-Topic: [C2.2] Get Element from uploaded file Thread-Index: AcylLoJVZ7F47PaKSKq/6PzNct7rggAAPUvg Message-ID: <78B923726E7D59429936580CF127E943A1EC5C845A@eu1rdcrdc1wx032.exi.nxp.com> References: <1321537197.76938.YahooMailNeo@web29503.mail.ird.yahoo.com> In-Reply-To: <1321537197.76938.YahooMailNeo@web29503.mail.ird.yahoo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: multipart/alternative; boundary="_000_78B923726E7D59429936580CF127E943A1EC5C845Aeu1rdcrdc1wx0_" MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.5.7110,1.0.211,0.0.0000 definitions=2011-11-17_03:2011-11-17,2011-11-17,1970-01-01 signatures=0 X-Virus-Checked: Checked by ClamAV on apache.org --_000_78B923726E7D59429936580CF127E943A1EC5C845Aeu1rdcrdc1wx0_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable There are many ways to accomplish this but below a possible approach: /**** Java Component to extract the filename **/ public interface FileNameExtractor { public String getFileName(String id); } public class PrototypeFileNameExtractor implements FileNameExtractor { public String getFileName(String id) { //TODO extract the fileName from the xml file identifiable by {id}= e.g. } } /** flowscript function to generate the pdf **/ function generatePDF() { var id =3D cocoon.parameters.id; var fileName =3D cocoon.getComponent('fileNameExtractor').getFileName(i= d); var response =3D cocoon.response; response.setHeader( "Content-Disposition", "attachment; filename=3D" + fileName + ".pdf" ); cocoon.sendPage('source2pdf/' + id); } Sitemap: ---------- From: Matthias M=FCller [mailto:pymote@yahoo.de] Sent: Thursday, November 17, 2011 2:40 PM To: users cocoon.apache.org Subject: [C2.2] Get Element from uploaded file Hi there, I do some xml -> pdf transformation using Coocon 2.2 and fop. My output fil= e name must contain a string that's in a certain element of my uploaded fil= e. I wonder how to access my uploaded file to extract the values? Do I need to access it via control flow? Is there something like a XPath evaluator? Matthias --_000_78B923726E7D59429936580CF127E943A1EC5C845Aeu1rdcrdc1wx0_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

There are= many ways to accomplish this but below a possible approach:

 

/**** Java Component to extract the filename **/=

 

public interface FileNameExtractor {<= /p>

=A0=A0=A0

=A0=A0=A0public String getFileName(String id);

 

}

 

public class PrototypeF= ileNameExtractor implements FileNameExtractor {

 

=A0=A0=A0=A0 public String getFileName(String id) {

=A0=A0=A0=A0=A0=A0=A0=A0 //TODO extract the fi= leName from the xml file identifiable by {id} e.g.

=A0=A0=A0=A0=A0}

 

}<= o:p>

 

 

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

 

function generatePDF() {

=A0=A0=A0 var id =3D cocoon.parameters.id;

=A0=A0=A0 var fileName =3D cocoon.getComponen= t('fileNameExtractor').getFileName(id);

=A0=A0=A0 var response =3D cocoon.response;=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0

=A0=A0=A0 response.setHeader(

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 "Content-Disposition",

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "attachmen= t; filename=3D" + fileName + ".pdf"

=A0=A0=A0 );=A0=A0=A0=A0=A0=A0=A0=A0

=A0=A0=A0 cocoon.sendPage('source2pdf/= ' + id);

 =

}

 

 

Sitemap:

----------

<!--

=A0 {1} id: unique identifier for the source xml used to generate the PDF=

--><= /p>

<map:match pattern=3D"generatePdf/*&= quot;>

=A0 <map:call= function=3D"generatePDF">

=A0=A0=A0 <map:parameter name=3D"id" value=3D&qu= ot;{1}"/>

=A0 <= /map:call>

</map:mat= ch>

 

<map:match pattern=3D"source2p= df/*">

=A0 <map= :generate src=3D"source/{1}.xml"/> <!-- assume our sources = are located in source folder -->

=A0 <map:transform src=3D"xslt/so= urce2poi.xslt"/>

=A0 <map:serialize type=3D"pdf"/>

</map:match>

 

 

From: Matthias M=FCller [mailto:pymote@yahoo.de]
Sent: Th= ursday, November 17, 2011 2:40 PM
To: users cocoon.apache.org
= Subject: [C2.2] Get Element from uploaded file

=

 

Hi there,

 =

I = do some xml -> pdf transformation using Coocon 2.2 and fop. My output fi= le name must contain a string that's in a certain element of my uploaded fi= le.

I wonder how to access my uploaded file to extract the values?<= o:p>

Do I need to access it via control flow?

Is there something= like a XPath evaluator?

 

Matthias<= /p>

= --_000_78B923726E7D59429936580CF127E943A1EC5C845Aeu1rdcrdc1wx0_--