当前位置: 首页>>代码示例>>Java>>正文


Java XMLResource.save方法代码示例

本文整理汇总了Java中org.eclipse.emf.ecore.xmi.XMLResource.save方法的典型用法代码示例。如果您正苦于以下问题:Java XMLResource.save方法的具体用法?Java XMLResource.save怎么用?Java XMLResource.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.emf.ecore.xmi.XMLResource的用法示例。


在下文中一共展示了XMLResource.save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: exportNupnXMLAsText

import org.eclipse.emf.ecore.xmi.XMLResource; //导入方法依赖的package包/类
/**
 * Returns the textual representation of a NUPN <toolspecific> model in XML.
 * @param nupnModel the NUPN model to serialize
 * @return the textual representation of its XML <toolspecific> construct.
 * @throws IOException
 */
public static StringBuffer exportNupnXMLAsText(EObject nupnModel) throws IOException {
	NupnResourceFactoryImpl npnrf = new NupnResourceFactoryImpl();
	ResourceSet resSet = new ResourceSetImpl();
	resSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
			.put(Resource.Factory.Registry.DEFAULT_EXTENSION, npnrf);
	// register your NupnPackage to the resource set so it has a reference
	// to Nupn.ecore
	NupnPackage ePackage = NupnPackage.eINSTANCE;
	resSet.getPackageRegistry().put(ePackage.getNsURI(), ePackage);
	Resource resource = npnrf.createResource(URI.createFileURI(PNML_NS_URI));
	XMLResource nupnRes = (XMLResource)resource;
	nupnRes.getContents().add(nupnModel);
	StringWriter sw = new StringWriter();
	nupnRes.save(sw, nupnRes.getDefaultSaveOptions());
	return sw.getBuffer();
}
 
开发者ID:lip6,项目名称:pnmlframework,代码行数:23,代码来源:NUPNWriter.java

示例2: serialize

import org.eclipse.emf.ecore.xmi.XMLResource; //导入方法依赖的package包/类
private String serialize(Marketplace rootElement) throws IOException {
	Map<String, Object> saveOptions = new HashMap<String, Object>();
	saveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
	// UTF-8 encoding is required per specification
	saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8");
	XMLResource resource = new XMLResourceImpl();
	resource.getContents().add(rootElement);
	StringWriter stringWriter = new StringWriter();
	resource.save(new URIConverter.WriteableOutputStream(stringWriter, resource.getEncoding()), saveOptions);
	return stringWriter.getBuffer().toString();
}
 
开发者ID:Itema-as,项目名称:dawn-marketplace-server,代码行数:12,代码来源:MarketplaceEndpoint.java

示例3: serialize

import org.eclipse.emf.ecore.xmi.XMLResource; //导入方法依赖的package包/类
public static String serialize(Node rootElement) throws IOException {
	Map<String, Object> saveOptions = new HashMap<String, Object>();
	saveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
	saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8");
	XMLResource resource = new XMLResourceImpl();
	resource.getContents().add(rootElement);
	StringWriter stringWriter = new StringWriter();
	resource.save(new URIConverter.WriteableOutputStream(stringWriter, resource.getEncoding()), saveOptions);
	return stringWriter.getBuffer().toString();
}
 
开发者ID:Itema-as,项目名称:dawn-marketplace-server,代码行数:11,代码来源:MarketplaceSerializer.java

示例4: export

import org.eclipse.emf.ecore.xmi.XMLResource; //导入方法依赖的package包/类
public String export(String id) throws Exception {
	this.createHeader(id);

	ResourceFactoryImpl resourceFactory = new XMLPersistenceMappingResourceFactoryImpl();
	URI emfURI = URI.createURI("http://kay-muench.de", true);
	XMLResource resource = (XMLResource) resourceFactory
			.createResource(emfURI);

	resource.setEncoding("UTF-8");
	resource.getContents().add(getReqIF());

	OutputStream os = new ByteArrayOutputStream();
	resource.save(os, null);
	return os.toString();
}
 
开发者ID:KayErikMuench,项目名称:reqiftools,代码行数:16,代码来源:ReqIF10Compiler.java


注:本文中的org.eclipse.emf.ecore.xmi.XMLResource.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。