Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Eclipse JET Guide
Previous Page Home Next Page

Using JET Transformations with XML Documents

By default, JET transformations expect an XML documents as input. XML documents are loaded into memory using the Eclipse Modeling Framework (EMF) XML document support.

XPath expressions against XML documents

The JET XPath processor handles XML documents according to the XPath 1.0 specification, with the following exception:

  • The XPath processor matches expressions containing unqualified names with elements and attributes that include a namespace prefix. XPath expressions can still determine the namespace URI of an element or attribute via the namespace-uri XPath function.

Details of XML Document loading

JET uses the EMF GenericXMLResourceFactoryImpl to load XML documents. Documents are loaded as follows:

  • If the document contains an XML schema declaration, and the Eclipse XSD feature is installed (org.eclipse.xsd), and the XSD file can be located, then the document is loaded according to the XSD.
  • When loading with an XSD, EMF will use the Java classes registered against the schema, if they exist. Otherwise, Dynamic EClasses will be generated, and loaded objects will be of type EObject.
  • If no XSD schema is supplied, or the schema cannot be located and there are no registered EMF Java classes for the schema, then XML elements are loaded as instances of AnyType.

The Model loader id for XML document loading is org.eclipse.jet.emfxml.

Loading XML documents during transformation execution

The launch framework automatically handles the loading of EMF resources passed to a JET Transformation as input. If required, JET templates can load other EMF-based documents during execution. XML documents may by loaded using the <c:load> and <c:loadContent> tags. The former loads a document from an file, while the second loads the document by parsing a text string.

The following loads the plugin.xml file from the transformation:

<c:load url="plugin.xml" var="pluginXML"/>

This is equivalent to:

<c:load url="plugin.xml" urlContext="transform" loader="org.eclipse.jet.emfxml" var="pluginXML"/>

The following example loads the file plugin.xml from a project 'myproject' in the Eclipse workspace.

<c:load url="myproject/plugin.xml" urlContext="workspace" var="pluginXML"/>

Finally, this example loads the contents of the c:loadContent tag as an XML document:

<c:loadContent var="myDoc">
        <item sku="123" price="1.55">Widget A</item>
        <item sku="456" price="2.99">Widget B</item>

Loading XML documents with non-standard extensions

The XML model loader is only associated with the 'xml' file extension. To load XML documents with other extensions as XML documents, configure the transformation as follows:

  1. Open the plugin.xml file in the root of the JET transformation project.
  2. Click on the Extensions tab.
  3. Expand the org.eclipse.jet.transform element in the All Extensions tree.
  4. Click on the (transform) element
  5. In the modelLoader field, and enter org.eclipse.jet.emfxml.
  6. In the modelExtension field, enter xml.

Image of plug-in editor showing setting of 'modelLoader' and 'modelExtension' attributes.

  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire