Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » XML output merging
XML output merging [message #30803] Tue, 14 August 2007 12:30 Go to next message
Francis Gavino is currently offline Francis GavinoFriend
Messages: 57
Registered: July 2009
Member
Given the following example structure of a model:
<module name="A">
<component name="1"/>
<component name="2"/>
</module>
I should be able to generate the components individually (transformations
are invoked separately). But I also need to generate a common XML file.
For example:
1. Generate component 1.
2. The output of the common XML file is:
<root>
<componentlist module="A">
<app>1</app>
</componentlist>
</root>
3. Generate component 2.
4. The expected output of the common XML file is:
<root>
<componentlist module="A">
<app>1</app>
<app>2</app>
</componentlist>
</root>

Question: How do I achieve this in JET? Is it possible to do xml merging?
I'm using version 0.7.1.

Thanks,
Francis
Re: XML output merging [message #30909 is a reply to message #30803] Tue, 14 August 2007 13:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Francis,

It would seem that for the common thing, you'd have module A as the
input and that would invoke that once for the module, while for the
component-level thing, you'd have each component as the input to the
template and do it once per component...


Francis wrote:
> Given the following example structure of a model:
> <module name="A">
> <component name="1"/>
> <component name="2"/>
> </module>
> I should be able to generate the components individually
> (transformations are invoked separately). But I also need to generate
> a common XML file. For example:
> 1. Generate component 1.
> 2. The output of the common XML file is:
> <root>
> <componentlist module="A">
> <app>1</app>
> </componentlist>
> </root>
> 3. Generate component 2.
> 4. The expected output of the common XML file is:
> <root>
> <componentlist module="A">
> <app>1</app>
> <app>2</app>
> </componentlist>
> </root>
>
> Question: How do I achieve this in JET? Is it possible to do xml
> merging? I'm using version 0.7.1.
>
> Thanks,
> Francis
>
Re: XML output merging [message #30979 is a reply to message #30909] Tue, 14 August 2007 15:01 Go to previous messageGo to next message
Francis Gavino is currently offline Francis GavinoFriend
Messages: 57
Registered: July 2009
Member
Ed,

Thanks for the reply. If I understood it correctly, the solution below
works when the module-level model is available in the transformation, or
when all components are available. But in the case where only the specific
component is available in the model passed to the template as input, can
that entry be merged if the common xml file is already existing?

BR,
Francis

Ed Merks wrote:

> Francis,

> It would seem that for the common thing, you'd have module A as the
> input and that would invoke that once for the module, while for the
> component-level thing, you'd have each component as the input to the
> template and do it once per component...


> Francis wrote:
>> Given the following example structure of a model:
>> <module name="A">
>> <component name="1"/>
>> <component name="2"/>
>> </module>
>> I should be able to generate the components individually
>> (transformations are invoked separately). But I also need to generate
>> a common XML file. For example:
>> 1. Generate component 1.
>> 2. The output of the common XML file is:
>> <root>
>> <componentlist module="A">
>> <app>1</app>
>> </componentlist>
>> </root>
>> 3. Generate component 2.
>> 4. The expected output of the common XML file is:
>> <root>
>> <componentlist module="A">
>> <app>1</app>
>> <app>2</app>
>> </componentlist>
>> </root>
>>
>> Question: How do I achieve this in JET? Is it possible to do xml
>> merging? I'm using version 0.7.1.
>>
>> Thanks,
>> Francis
>>
Re: XML output merging [message #31052 is a reply to message #30979] Tue, 14 August 2007 17:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Francis,

Nothing generic is going to be smart enough to know how to merge the
specific results properly.


Francis wrote:
> Ed,
>
> Thanks for the reply. If I understood it correctly, the solution below
> works when the module-level model is available in the transformation,
> or when all components are available. But in the case where only the
> specific component is available in the model passed to the template as
> input, can that entry be merged if the common xml file is already
> existing?
>
> BR,
> Francis
>
> Ed Merks wrote:
>
>> Francis,
>
>> It would seem that for the common thing, you'd have module A as the
>> input and that would invoke that once for the module, while for the
>> component-level thing, you'd have each component as the input to the
>> template and do it once per component...
>
>
>> Francis wrote:
>>> Given the following example structure of a model:
>>> <module name="A">
>>> <component name="1"/>
>>> <component name="2"/>
>>> </module>
>>> I should be able to generate the components individually
>>> (transformations are invoked separately). But I also need to
>>> generate a common XML file. For example:
>>> 1. Generate component 1.
>>> 2. The output of the common XML file is:
>>> <root>
>>> <componentlist module="A">
>>> <app>1</app>
>>> </componentlist>
>>> </root>
>>> 3. Generate component 2.
>>> 4. The expected output of the common XML file is:
>>> <root>
>>> <componentlist module="A">
>>> <app>1</app>
>>> <app>2</app>
>>> </componentlist>
>>> </root>
>>>
>>> Question: How do I achieve this in JET? Is it possible to do xml
>>> merging? I'm using version 0.7.1.
>>>
>>> Thanks,
>>> Francis
>>>
>
>
Re: XML output merging [message #31644 is a reply to message #30803] Mon, 27 August 2007 15:47 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Francis:

There is no generic tool for XML merges, and as Ed has indicated, a generic
tool would need a lot of hints about your particular model.

Here is how I've seen XML merges done with JET:

1) use c:load to load the existing XML document into memory.
2) modify the XML document in-memory using tags like c:addElement,
c:addTextElement, c:removeElement and c:copyElement. A particularly powerful
approach is to use c:loadContent to create your "new" content from a
template, and the using c:copyElement to move it into the in-memory tree.
3) Save the content by using c:dump inside a template.

Paul

"Francis" <fgavino@gmail.com> wrote in message
news:ac38e79c94c147972aefa827903344c1$1@www.eclipse.org...
> Given the following example structure of a model:
> <module name="A">
> <component name="1"/>
> <component name="2"/>
> </module>
> I should be able to generate the components individually (transformations
> are invoked separately). But I also need to generate a common XML file.
> For example:
> 1. Generate component 1.
> 2. The output of the common XML file is:
> <root>
> <componentlist module="A">
> <app>1</app>
> </componentlist>
> </root>
> 3. Generate component 2.
> 4. The expected output of the common XML file is:
> <root>
> <componentlist module="A">
> <app>1</app>
> <app>2</app>
> </componentlist>
> </root>
>
> Question: How do I achieve this in JET? Is it possible to do xml merging?
> I'm using version 0.7.1.
>
> Thanks,
> Francis
>
Re: XML output merging [message #31744 is a reply to message #31644] Tue, 28 August 2007 16:45 Go to previous message
Francis Gavino is currently offline Francis GavinoFriend
Messages: 57
Registered: July 2009
Member
Thanks Paul and Ed, I agree that merging specific xml content needs
specific logic. At first I thought it was possible to use something
similar to jmerge with regular expressions. Thanks for the tip about the
load-and-modify approach.

Francis
Previous Topic:[Announce] Not monitoring group til Aug 24
Next Topic:Accessing EMF model EEnum isSetX() in template
Goto Forum:
  


Current Time: Thu Mar 28 16:20:36 GMT 2024

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

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

Back to the top