Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Generates an XSD with annotations from an ECore model
Generates an XSD with annotations from an ECore model [message #596883] Mon, 10 October 2005 14:31
Julien is currently offline 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);
}
Previous Topic:resolve XSDSimpleTypeDefinition
Next Topic:How to print logical view of schema?
Goto Forum:
  


Current Time: Tue Sep 23 10:22:53 GMT 2014

Powered by FUDForum. Page generated in 0.02333 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software