org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl Java Examples

The following examples show how to use org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModelWriter.java    From orcas with Apache License 2.0 6 votes vote down vote up
public static String getSkriptXml( Model pModel )
{
  Resource.Factory.Registry lRegistry = Resource.Factory.Registry.INSTANCE;
  Map<String,Object> lMap = lRegistry.getExtensionToFactoryMap();
  lMap.put( "xml", new XMLResourceFactoryImpl() );

  ResourceSet lResourceSet = new ResourceSetImpl();
  Resource lResource = lResourceSet.createResource( URI.createFileURI( "*.xml" ) );

  ((XMLResource)lResource).getDefaultSaveOptions();

  lResource.getContents().add( pModel );
  try
  {
    ByteArrayOutputStream lByteArrayOutputStream = new ByteArrayOutputStream();
    lResource.save( lByteArrayOutputStream, Collections.EMPTY_MAP );

    return new String( lByteArrayOutputStream.toByteArray() );
  }
  catch( IOException e )
  {
    throw new RuntimeException( e );
  }
}
 
Example #2
Source File: XtextFileLoader.java    From orcas with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings( "unchecked" )
public T loadModelXml( String pFilename, String pNamespaceUri, EPackage pEPackage )
{
  EPackage.Registry.INSTANCE.put( pNamespaceUri, pEPackage );
  Resource.Factory.Registry lRegistry = Resource.Factory.Registry.INSTANCE;
  Map<String, Object> lMap = lRegistry.getExtensionToFactoryMap();
  lMap.put( "xml", new XMLResourceFactoryImpl() );

  ResourceSet lResourceSet = new ResourceSetImpl();
  Resource lResource = lResourceSet.createResource( URI.createFileURI( pFilename ) );

  ((XMLResource) lResource).getDefaultSaveOptions();

  try
  {
    lResource.load( Collections.EMPTY_MAP );
  }
  catch( IOException e )
  {
    throw new RuntimeException( e );
  }

  return (T) lResource.getContents().get( 0 );
}
 
Example #3
Source File: ChartActionBarContributor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private void doSave ( final String file ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();

    rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new XMLResourceFactoryImpl () ); //$NON-NLS-1$
    final URI fileUri = URI.createFileURI ( file );
    final Resource resource = rs.createResource ( fileUri );
    resource.getContents ().add ( this.chart );

    final Map<Object, Object> options = new HashMap<Object, Object> ();
    //             options.put ( XMIResource., value )
    resource.save ( options );
}
 
Example #4
Source File: Express2EMF.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
public void writeEMF(String fileName) {
	ResourceSet metaResourceSet = new ResourceSetImpl();
	metaResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMLResourceFactoryImpl());

	URI resUri = URI.createURI(fileName);
	Resource metaResource = metaResourceSet.createResource(resUri);
	metaResource.getContents().add(schemaPack);
	try {
		metaResource.save(null);
	} catch (Exception e) {
		LOGGER.error("", e);
	}
}
 
Example #5
Source File: XSDSchemaReader.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
public void writeEMF(String fileName) {
	ResourceSet metaResourceSet = new ResourceSetImpl();
	metaResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMLResourceFactoryImpl());

	URI resUri = URI.createURI(fileName);
	Resource metaResource = metaResourceSet.createResource(resUri);
	metaResource.getContents().add(ePackage);
	try {
		metaResource.save(null);
	} catch (Exception e) {
		e.printStackTrace();
	}
}