Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Ecore to XSD
Ecore to XSD [message #602872] Tue, 04 March 2008 12:31
Vipul is currently offline Vipul
Messages: 6
Registered: July 2009
Junior Member
Hi,
I want to generate the xsd from an Ecore file. I have written some code
which uses the EcoreSchemaBuilder to create the xsd file.

Here is the code snippet:

EPackage ePackage = getEPackage(ecoreFilePath);

EPackage.Registry.INSTANCE.put(XSDPackageImpl.eNS_URI,
XSDPackageImpl.eINSTANCE);
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(
XSDPackageImpl.eNS_URI, XSDPackageImpl.eINSTANCE);
resourceSet.getResourceFactoryRegistry()
.getExtensionToFactoryMap().put(XSD_EXTENSION,new
XSDResourceFactoryImpl());

ExtendedMetaData extendedMetaData = new BasicExtendedMetaData();
EcoreSchemaBuilder xsdBuilder = new EcoreSchemaBuilder(extendedMetaData);
XSDSchema xsd = xsdBuilder.getSchema(ePackage);

Resource xsdResource = resourceSet.createResource(URI
.createPlatformResourceURI(xsdFilePath.toString()));
xsdResource.getContents().add(xsd);

....code to save the xsd resource.......

My problem is that i donot need any ecore references in the xsd file. It
should be the plain xsd file without any ecore declaration in it.

Any pointers on this will really help.....

Thanks in advance,
Vipul
Previous Topic:Create new DOM document from XSD schema
Next Topic:Eclipse : Write XML using XSD
Goto Forum:
  


Current Time: Thu Aug 21 04:35:46 EDT 2014

Powered by FUDForum. Page generated in 0.01572 seconds