It's not an API type thing, but you
can look for the EMF2DOM(SSE?)Adapter [there's one for straight DOM and
one for SSE] on the EMF object (see EcoreUtil.getExistingAdapter()). From
there, you should be able to track through to the corresponding XML node.
The adapter is an EMF adapter that responds to changes in the EMF model,
and uses the Translators to convert the value to one that can be parsed
into an XML change (either element or attribute value). When using SSE,
there's something similar on the SSE model side (another adapter looking
for changes directly to the SSE model), so if you track back an SSE model
and making changes, you'll be in sync. I don't believe DOM responds to
changes in the DOM, so be aware that any changes you make there, you'll
have to make in the EMF model as well, if they correspond. Also note that
when you change the EMF model, it'll generate the same event into the DOM
as well. You'll probably have to do a little digging, and I'd recommend
being very careful doing this as making programmatic changes to the XML
is not considered a best practice. I'd just recommend that you ensure you've
evaluated all other options before doing this.
Generally, anything available in the
document (e.g. Namespaces, etc) is available through EMF API. Might be
worth double checking that there's not an existing EMF API to do whatever
it is you're about to do.
"Developers are like artists; they produce their best work if they
have the freedom to do so, but they need good tools." -- Werner Vogels
Cameron Bateman <cameron.bateman@xxxxxxxxxx> Sent by: wtp-dev-bounces@xxxxxxxxxxx
12/07/2006 08:35 PM
Please respond to
"General discussion of project-wide or architectural issues."
[wtp-dev] EMF2XML translation reverse
Given an EMF object create throught XML2EMF/ArtifactEdit
it currently possible to map back to the XML node that generated that
object? If not, has this ever be considered and would be a lot of
wtp-dev mailing list