Eclipse UML2를 사용하여 Visual Paradigm 생성 XMI 파일 구문 분석 (Using Eclipse UML2 to parse a Visual Paradigm generated XMI file)


문제 설명

Eclipse UML2를 사용하여 Visual Paradigm 생성 XMI 파일 구문 분석 (Using Eclipse UML2 to parse a Visual Paradigm generated XMI file)

Visual Paradigm 8로 클래스 다이어그램을 그리고 프로젝트를 XMI 2.1 파일로 내보냈습니다(UML2용 내보내기). 따라서 두 개의 파일(test.xmi.umltest.xmi.profile.uml)이 있습니다. test.xmi.uml을 구문 분석하기 위해 eclipse uml2 및 emf를 사용하여 이 Java 코드를 작성했습니다.

ResourceSet set = new ResourceSetImpl();
set.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Resource res =  set.getResource(URI.createFileURI("C:\\test.xmi.uml"), true);
EObject eobj = res.getContents().get(0);

그러나 출력 개체(eobj)는 AnyTypeImpl 잘 읽을 수 없습니다. 이 파일을 구문 분석하여 org.eclipse.uml2.uml.Model 객체와 같은 올바른 형식의 객체를 얻으려면 어떻게 해야 합니까?


참조 솔루션

방법 1:

I have finally found my answer: Using org.eclipse.uml2.uml.resources.util.UMLResourcesUtil.init() to initialize the parameters needed to parse the .uml file. So the code must be like this:

ResourceSet set = new ResourceSetImpl();
UMLResourcesUtil.init(set);
Resource res = set.getResource(typesUri, true);
EObject eobj = res.getContents().get(0);

the eobj is an instance of org.eclipse.uml2.uml.Model which is a well‑formed object.

(by Ehsan SoleimaniEhsan Soleimani)

참조 문서

  1. Using Eclipse UML2 to parse a Visual Paradigm generated XMI file (CC BY‑SA 2.5/3.0/4.0)

#xmi #visual-paradigm #uml #Parsing #java






관련 질문

Java 소스 코드에 대한 XMI 파일을 생성하는 방법은 무엇입니까? (How to generate XMI file for the java source code?)

UML/XMI 파일을 StarUML로 가져오는 방법은 무엇입니까? (How to import any UML/XMI files to StarUML?)

가져오기/내보내기 : XMI용 netbeans (Import/export : netbeans for XMI)

XMI 형식의 UML 다이어그램 (UML diagram in XMI Format)

연관이 아닌 UML 클래스 속성 목록에 대한 XPath 쿼리 (XPath query for list of UML class attributes that are not associations)

Eclipse UML2를 사용하여 Visual Paradigm 생성 XMI 파일 구문 분석 (Using Eclipse UML2 to parse a Visual Paradigm generated XMI file)







코멘트