[JET] Running JET via Java Code only returns static contents of the template [message #538152] |
Sat, 05 June 2010 19:13 |
Christian Kurze Messages: 16 Registered: July 2009 |
Junior Member |
|
|
Hi,
I try to run a JET transformation via Java Code as described here: http://wiki.eclipse.org/M2T-JET-FAQ/How_do_I_run_a_JET_templ ate_from_Java%3F
The transformaiton starts and outputs a String. My problem is that the passed org.w3c.dom.Document is not parsed. The JET tags c:get and c:iterate have no effect, just the "static" contents of my template are returned, but no information from the passed XML file is returned.
Has anybody any idea what I'm doing wrong?
My source code calling the template (curFile ist of type IFile):
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(curFile.getContents());
final JET2Context jet2Context = JET2Helpers.createJETContext(doc, null);
final BufferedJET2Writer jet2Writer = JET2Helpers.createJETWriter();
try {
JET2TemplateManager.run(new String[] {"myTransformation.jet"}, new JET2TemplateManager.ITemplateOperation() {
public void run(ITemplateRunner templateRunner) {
templateRunner.generate("templates/newCatalog2CSV.jet", jet2Context, jet2Writer);
}
});
System.out.println(jet2Writer.getContent());
} catch (BundleException be) {
MessageDialog.openError(shell, "Fehler", be.getMessage());
}
My JET is the following:
SUPPLIER_PID;SUPPLIER_IDREF;DESCRIPTION_SHORT;EAN;PRICE;PRICE_VALID_FROM;PRICE_VALID_TO
Version: <c:get select="/CAT/@version" />
<c:iterate select="//T_NEW_CATALOG" var="catalog">
<c:iterate select="$catalog/PRODUCT" var="product">
<c:get select="$product/SUPPLIER_PID" />;<c:get select="$product/SUPPLIER_IDREF" />;<c:get select="$product/PRODUCT_DETAILS/DESCRIPTION_SHORT" />;<c:get select="$product/PRODUCT_DETAILS/EAN" />;<c:get select="$product/PRODUCT_PRICE_DETAILS/PRODUCT_PRICE" />;<c:get select="$product/PRODUCT_PRICE_DETAILS/VALID_START_DATE" />;<c:get select="$product/PRODUCT_PRICE_DETAILS/VALID_END_DATE" />
</c:iterate>
</c:iterate>
The Document is read correctly, in the debugger I see all the tags. If I execute the transformation manually everything works fine. Just the first line as well as "Version" is included in the output String when running the template via Java Code.
I call a simple dump-template via code an everything looks fine. I cannot find my mistake. Why does a dump work, but a "real" template not?
Thanks in advance for any help.
Chris
[Updated on: Sun, 06 June 2010 08:23] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02335 seconds