Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [JET] Update input xml dynamically in JET
[JET] Update input xml dynamically in JET [message #661024] Tue, 22 March 2011 18:56 Go to next message
yongjiezheng is currently offline yongjiezhengFriend
Messages: 10
Registered: March 2011
Location: California
Junior Member
Hi,

I'm a new JET user. Can anyone let me know if it is possible to update the input xml (set the content value of some node) dynamically in JET template? I tried <c:addTextElement>, but it seems not the right tag to use. Nothing was changed in the input xml file after the code generation was done.

Thanks a lot,
William
Re: [JET] Update input xml dynamically in JET [message #661027 is a reply to message #661024] Tue, 22 March 2011 19:07 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
William:

You are close. JET doesn't update anything automatically. If you want to update a file (say the input model), you have to use a take like ws:file (that invokes a template to specify the content).

So, your sequence of actions would be:

<c:addTextElement > ... or whatever
<ws:file path="...input path..." template="templates/updateInput.jet" />

and updateInput.jet would contain:

<c:dump select="/*" />


c:dump was really intended for debugging. It sometimes does a less than perfect job of representing the input as XML (especially if the input isn't XML).

Lastly, if you are invoking the JET transform from the Eclipse Run UI, or from JET2Platform.runtTransformOnResource(), then the JET variable org.eclipse.jet.resource.fullPath contains the right value for the path attribute on <ws:file>

<ws:file path="{org.eclipse.jet.resource.fullPath}" ... />

Re: [JET] Update input xml dynamically in JET [message #661047 is a reply to message #661027] Tue, 22 March 2011 21:45 Go to previous messageGo to next message
yongjiezheng is currently offline yongjiezhengFriend
Messages: 10
Registered: March 2011
Location: California
Junior Member
Hi Paul,

This is perfect. Thank you so much.

BTW, does this mean that I have to overwrite the whole input document even if I just want to update a small portion (one element) of it?

William
Re: [JET] Update input xml dynamically in JET [message #661048 is a reply to message #661024] Tue, 22 March 2011 21:50 Go to previous messageGo to next message
yongjiezheng is currently offline yongjiezhengFriend
Messages: 10
Registered: March 2011
Location: California
Junior Member
Hi Paul,

This is perfect. Thank you so much.

BTW, does this mean that I have to overwrite the whole input document even if I just want to update a small portion (one element) of it?

William
Re: [JET] Update input xml dynamically in JET [message #661074 is a reply to message #661048] Wed, 23 March 2011 00:36 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
William:

Yes, ws:file writes the whole file, no partial update.

Paul
Previous Topic:WorkflowEngine run
Next Topic:[Acceleo] white lines into code and code move
Goto Forum:
  


Current Time: Tue Apr 16 14:31:19 GMT 2024

Powered by FUDForum. Page generated in 0.27629 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top