use Generated file in memory directly [message #1067592] |
Tue, 09 July 2013 09:45  |
Eclipse User |
|
|
|
Hi all ,
I want guidance please about xpnad generation procedure. I worte xpand template to generate another xpand template and I want to run the generated template when it is still in memory without writing it to disk .
I appreciate your guidance .
Thanks in advance.
[Updated on: Tue, 09 July 2013 09:57] by Moderator
|
|
|
Re: use Generated file in memory directly [message #1067834 is a reply to message #1067592] |
Wed, 10 July 2013 15:19   |
Eclipse User |
|
|
|
Hi
the following works for me but i dont know if it will work in all cases
public static void main(String[] args) {
final Template template = XpandParseFacade.file(new StringReader("«DEFINE test FOR String»«FILE 'x.text'»Hallo «this»!«ENDFILE»«ENDDEFINE»"), "test/Test.xpt");
Output out = new OutputImpl();
out.addOutlet(new Outlet("my-gen"));
ResourceManager resourceManager = new ResourceManagerDefaultImpl() {
@Override
public Resource loadResource(String fullyQualifiedName,
String extension) {
if ("test::Test".equals(fullyQualifiedName)){
return template;
}
return super.loadResource(fullyQualifiedName, extension);
}
};
ProtectedRegionResolver prs = null;
ProgressMonitor monitor = new NullProgressMonitor();
ExceptionHandler exceptionHandler = null;
NullEvaluationHandler nullEvaluationHandler = null;
VetoableCallback callback = null;
XpandExecutionContext execCtx = new XpandExecutionContextImpl(resourceManager , out, prs, new HashMap<String, Variable>(), monitor, exceptionHandler, nullEvaluationHandler, callback);
XpandFacade.create(execCtx).evaluate("test::Test::test", "xxx");
}
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05000 seconds