edit this page - page history - about editing

Loading EMF XSD Models at Runtime


I wanted to be able to get the XSDSimpleTypeDefinition of a particular defined XSD type in my Eclipse plugin environment, i.e.


Which was stored in an XSD file


The solution is to load the XSD file (through a URI) at runtime using EMF, and then iterating through this file to find the relevant data types. These can then be saved and referred to as necessary.

URI uri = URI.createURI("platform:/plugin/org.openiaml.model/model/datatypes.xsd");
EObject root = ModelLoader.load(uri);
XSDSchema schema = (XSDSchema) root;
for (XSDTypeDefinition type : schema.getTypeDefinitions()) {
  // ... checks with getURI()

See how I implemented this in IAML.
Categories: Java | EMF | Code Snippets
edit this page - what links to here? - page history - top
Last edited by jevon jevon 96 months ago