
Some parts of this message have been removed.
Learn more about Nabble's
security policy.
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 <Robby.Pelssers@...>
An: "users@..." <users@...>; Matthias Müller <pymote@...>
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 = cocoon.parameters.id;
var fileName = cocoon.getComponent('fileNameExtractor').getFileName(id);
var response = cocoon.response;
response.setHeader(
"Content-Disposition",
"attachment; filename=" + fileName + ".pdf"
);
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>
From: Matthias Müller [mailto:pymote@...]
Sent: Thursday, November 17, 2011 2:40 PM
To: users cocoon.apache.org
Subject: [C2.2] Get Element from uploaded file
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?