Example: Cloning and copying XML elements across documents with EOL

// The contacts list in contacts.xml
var contacts = Contacts!t_contacts.all.first();

// The vcard element in templates.xml
var vcard = Templates!t_vcard.all.first();

// Copy the vcard into the contacts document
var clone = Contacts.document.importNode(vcard, true);

// Put it under the contacts list
contacts.appendChild(clone);
<?xml version="1.0"?>
<templates>
  <vcard>
    <name/>
    <email/>
    <address number="" postcode=""/>
  </vcard>
</templates>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<contacts>
  <vcard>
    <name/>
    <email/>
    <address number="" postcode=""/>
  </vcard>
</contacts>

Check out the code from the SVN:

  • go to the SVN repository
  • navigate to trunk/examples
  • check out the org.eclipse.epsilon.examples.plainxml.copyfromtemplate project

Once you have checked out/imported the code, to run the example you need to go through the following steps:

  1. register any .ecore metamodels in the org.eclipse.epsilon.examples.plainxml.copyfromtemplate project
  2. right click the .launch file in the org.eclipse.epsilon.examples.plainxml.copyfromtemplate project
  3. select Run as... and click the first item in the menu that pops up

What's this?

In this example, we use the plain XML driver of Epsilon to clone and copy XML elements across different documents with EOL.

What are .emf files?

.emf files are Ecore metamodels expressed using the Emfatic textual syntax.

More examples...

Epsilon Object Language
Epsilon Transformation Language
Epsilon Generation Language
Epsilon Validation Language
Epsilon Merging Language
Epsilon Flock
Combining the Epsilon Languages
EuGENia
EUnit

Even more examples...

More examples are available in the examples folder of the SVN repository.