Generates an XSD with annotations from an ECore model [message #596883] |
Mon, 10 October 2005 14:31 |
Julien Messages: 15 Registered: July 2009 |
Junior Member |
|
|
I build an ECore model which uses EAnnotation. And when I generate an XSD
file from my ECore model, the Annotations are not added.
EPackage myPackage = EcoreFactory.eINSTANCE.createEPackage();
myPackage.setName(PACKAGE_NAME);
myPackage.setNsPrefix(PACKAGE_NS_PREFIX);
myPackage.setNsURI(PACKAGE_NS_URI);
// documentList is a list of EClassifier
myPackage.getEClassifiers().addAll(documentList);
EAnnotation myAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
myAnnotation.setSource(ANNOTATION_SOURCE);
myAnnotation.getDetails().put("ecore:isRootDocument", "true");
myPackage.getEAnnotations().add(myAnnotation);
// XMLSchema building
EcoreXMLSchemaBuilder xmlSchemaBuilder = new EcoreXMLSchemaBuilder();
Collection resultXmlSchemaBuilder = xmlSchemaBuilder.generate(myPackage);
// Register XML resource factory
org.eclipse.emf.ecore.resource.Resource resource = new
XSDResourceImpl(URI.createFileURI(MY_URI));
resource.getContents().addAll(resultXmlSchemaBuilder);
Map properties = new HashMap();
properties.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
try {
resource.save(properties);
} catch (IOException e) {
ExceptionHandler.processException(e, null);
}
|
|
|
Powered by
FUDForum. Page generated in 0.01330 seconds