當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。