cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthias Müller <>
Subject Re: [C2.2] Get Element from uploaded file
Date Thu, 17 Nov 2011 14:53:31 GMT
Thanks for the quick response.
Actually I already know how to rename a
 file, although my approach isn't that elegant as yours. But what I need
 to know is the way I can access the uploaded xml file with XPath to 
read the information that I need. In other words: the magic that happens
 inside your PrototypeFileNameExtractor. String id contains the 
filename, how do I create a dom object with it?

 Von: Robby Pelssers <>
An: "" <>; Matthias Müller <>

Gesendet: 15:04 Donnerstag, 17.November 2011
Betreff: RE: [C2.2] Get Element from uploaded file

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 =;
    var fileName = cocoon.getComponent('fileNameExtractor').getFileName(id);
    var response = cocoon.response;                         
                "attachment; filename=" + fileName + ".pdf"
    cocoon.sendPage('source2pdf/' + id);
  {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: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"/>
From:Matthias Müller [] 
Sent: Thursday, November 17, 2011 2:40 PM
To: users
Subject: [C2.2] Get Element from uploaded file
Hi there,
I do some xml -> pdf transformation using Coocon 2.2 and fop. My output file name must
contain a string that's in a certain element of my uploaded file.
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?
View raw message