Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "MoDisco/Components/XML/Documentation/0.9"

< MoDisco‎ | Components‎ | XML
(Install)
Line 10: Line 10:
 
Concepts for Document Types Declarations are not managed here.
 
Concepts for Document Types Declarations are not managed here.
 
Note : there is no composite 'ownedAttribute' reference between Element and Attribute type to avoid ambiguous duplicate owning possibilities considering 'chidren' reference.
 
Note : there is no composite 'ownedAttribute' reference between Element and Attribute type to avoid ambiguous duplicate owning possibilities considering 'chidren' reference.
 
=== Requirements ===
 
 
To use the plug-in you need:
 
* JDK 1.5 or above
 
* a version of Eclipse 3.5 or above with the following set of plug-ins installed
 
** [[EMF|EMF]] 2.5.0 or higher
 
 
=== Install ===
 
 
You can [[MoDisco/Installation|install]] the XML discoverer and associated metamodel from the MoDisco update site.
 
 
=== Source Repository ===
 
 
All of the source code is stored in a public source repository, which you can access at:
 
 
https://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.modisco/plugins/trunk/org.eclipse.modisco.xml.discoverer/
 
  
 
== XML Discoverer ==
 
== XML Discoverer ==
Line 40: Line 23:
  
 
Since the metamodel is a subset of W3C XML concepts, the end user should be aware of some limitations in serializing back some advanced XML contents.
 
Since the metamodel is a subset of W3C XML concepts, the end user should be aware of some limitations in serializing back some advanced XML contents.
 
=== Requirements ===
 
 
To use the plug-in you need:
 
* JDK 1.5 or above
 
* a version of Eclipse 3.5 or above with the following set of plugins installed
 
** [[EMF|EMF]] 2.5.0 or higher
 
** [[MoDisco/Components/DiscoverersManager|Discoverers Manager]]
 
** [[#XML_Metamodel|Generic XML metamodel]]
 
  
 
=== User manual ===
 
=== User manual ===
Line 111: Line 85:
 
For more details see the java documentation on the XMLModelDiscoverer class.
 
For more details see the java documentation on the XMLModelDiscoverer class.
  
=== Install ===
+
== Install ==
 +
 
 +
You can [[MoDisco/Installation|install]] the XML discoverer and associated metamodel from the MoDisco update site.
 +
 
 +
== Source Repository ==
  
==== Install from SVN ====
+
All of the source code is stored in the Eclipse public source repository:
  
* connect to the SVN repository with anonymous access :
+
* XML metamodel : https://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.modisco/plugins/trunk/org.eclipse.gmt.modisco.xml/
URL = https://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.modisco
+
* XML discoverer : https://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.modisco/plugins/trunk/org.eclipse.modisco.xml.discoverer/
  
* navigate in repository following the 'plugins/trunk' path.
 
* check-out the project named 'org.eclipse.gmt.modisco.infra.xml.discoverer' .
 
* Use the "export" menu to export this project as a plug-in (Deployable plug-ins and fragments) in your Eclipse installation. Don't forget to choose the "Package plug-ins as individual jar archives" option.
 
* restart Eclipse to take this plug-in into account
 
  
 
{{MoDisco}}
 
{{MoDisco}}
 
[[Category:MoDisco]]
 
[[Category:MoDisco]]

Revision as of 08:06, 29 March 2011

MoDisco
Website
Download
Community
Mailing ListForums
Bugzilla
Open
Help Wanted
Bug Day
Contribute
Browse SourceProject Set File

XML Metamodel

Definition

Ecore Generic XML metamodel definition

Concepts are described in W3C XML Recommendation (document and logical structures sections). Concepts for Document Types Declarations are not managed here. Note : there is no composite 'ownedAttribute' reference between Element and Attribute type to avoid ambiguous duplicate owning possibilities considering 'chidren' reference.

XML Discoverer

The goal of the Generic XML Discoverer plug-in is to allow generic extractions of XML information from a XML file, without the need for a metamodel dedicated to a conforming Document Type Definition(DTD) or XML Schema Description (XSD).

Details

Considering XML files conforming to DTD or XSD, it will be more convenient to have some dedicated metamodels to manipulate information. However, Generic XML Discoverer is an alternative for miscellaneous XML files (no or uncommon DTD/XSD).

This plug-in aims at analyzing any XML file providing a model describing the information found, conforming to the Generic XML metamodel. Moreover, it allows to serialize the xml file back from the model. Thus, some M2M transformations might be used jointly to upgrade some xml files.

Since the metamodel is a subset of W3C XML concepts, the end user should be aware of some limitations in serializing back some advanced XML contents.

User manual

Discovering and browsing from contextual menu

Right-click on a XML file and select the XML discoverer (Discovery > Discoverers > Discover XML Model...):

Menu in Eclipse to discover a XML model

A discovery parameters dialog opens to let you specify the parameters of the discovery:

MoDisco Launching discovery org.eclipse.modisco.xml.discoverer.png

  • Set SERIALIZE_TARGET to true if you want to save the model to a file
  • You can define TARGET_URI to the location of a file in your workspace. If it is not defined and SERIALIZE_TARGET is true, a model file with a default name will be created in the project.
    Beware: the file will be overwritten if it already exists!

Once launched, a progress dialog will appear as soon as the operation begins. Depending on the size of your file, the reverse engineering process might take some time to complete:

MoDisco discoverer org.eclipse.modisco.xml.discoverer in progress.png

At the end of the process, the newly created model file is added to the root of your project if you set SERIALIZE_TARGET to true:

XML model in the package explorer

And the model is opened in the default model browser if you selected Open model in editor after discovery:

XML model viewed with the MoDisco model browser

The model file for the XML file (with a filename ending in "_xml.xmi" by convention) can be opened in any model browser:

"Open With" on a XML model

Discoverer API

First, add the following plug-in dependencies to your project (Require-Bundle in your Manifest.MF):

  • org.eclipse.modisco.infra.discovery.core
  • org.eclipse.gmt.modisco.xml
  • org.eclipse.modisco.xml.discoverer

You can launch the discovery of a XML model from a file programmatically, and get the resulting model:

XMLModelDiscoverer discoverer = new XMLModelDiscoverer();
// you can set some parameters
discoverer.setIgnoreWhitespace(true);
discoverer.setLightweightModel(false);
// launch the discovery
discoverer.discoverElement(xmlFile, monitor);
// get the resulting resource containing the XML model
Resource xmlResource = discoverer.getTargetModel();

To have a monitor to pass to the discoverElement method, you can either call the discoverer in an Eclipse Job, or pass a new NullProgressMonitor if you don't need progress reporting.

Some options can be set for the discovery operation :

  • IGNORE_WHITESPACE : ignore white space in text portions
  • LIGHTWEIGHT : to minimize the memory size of the obtained model. If set to true : comments are ignored, text portions with only spaces and line delimiters are ignored.

The XML content can be serialized back since the model elements are contained in a dedicated org.eclipse.emf.ecore.resource.Resource implementation.

For more details see the java documentation on the XMLModelDiscoverer class.

Install

You can install the XML discoverer and associated metamodel from the MoDisco update site.

Source Repository

All of the source code is stored in the Eclipse public source repository:



MoDisco
Components Infrastructure: KDM · SMM · GASTM · Model Browser · Discovery Manager · MoDisco Workflow · Query Manager · Facet Manager · Metrics Visualization Builder · KDM Source Extension
Technologies: Java · JEE · EjbJar · WebApp · XML
Use Cases: Simple Transformation Chain · Model Filter
Help Installation · SVN
Project API Policy · Retention Policy · Project Plan · metrics · Accessibility Guidelines · Capabilities Disablement

Back to the top