Created
June 27, 2024 02:47
-
-
Save sz332/21f31bc3bfd787dc211c2608728000fb to your computer and use it in GitHub Desktop.
Reading SysML XMI file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestLoadFile { | |
public static void main(String[] args) { | |
UMLResourcesUtil.initGlobalRegistries(); | |
var registry = Resource.Factory.Registry.INSTANCE; | |
var m = registry.getExtensionToFactoryMap(); | |
m.put("xmi", new XMIResourceFactoryImpl()); | |
var resourceSet = new ResourceSetImpl(); | |
SysMLPackageImpl.init(); | |
loadFile(resourceSet); | |
} | |
private static void loadFile(ResourceSet resourceSet) { | |
var resource = resourceSet.createResource(URI.createFileURI("/home/myuser/sysml_2.xmi")); | |
try { | |
resource.load(Collections.emptyMap()); | |
var contents = resource.getContents(); | |
System.out.println(contents); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment