Having the following code I'm loading a BPMN model.
// dummy URI, loading done through input stream
URI uri = URI.createURI("data.bpmn");
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.createResource(uri, "org.eclipse.bpmn2.content-type.xml");
resource.load(contentStream, null);
Saving the resource resource.save(outputStream, null);
manipulates the output and adds data.bpmn#
to references:
<bpmndi:BPMNShape id="BPMNShape_StartEvent_1" bpmnElement="data.bpmn#StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="162.0" y="182.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_1" labelStyle="data.bpmn#BPMNLabelStyle_1">
<dc:Bounds height="15.0" width="68.0" x="146.0" y="218.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
Where it looks like this coming from the input stream:
<bpmndi:BPMNShape id="BPMNShape_StartEvent_1" bpmnElement="StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="162.0" y="182.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_1" labelStyle="BPMNLabelStyle_1">
<dc:Bounds height="15.0" width="68.0" x="146.0" y="218.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
Is there a way to force EMF not to manipulate the references?
This is how I solved it:
ResourceSet resourceSet = new ResourceSetImpl();
XMLResource resource = (XMLResource) resourceSet.createResource(modelUri, "org.eclipse.bpmn2.content-type.xml");
XMLResource.URIHandler uriHandler = new URIHandlerImpl() {
@Override
public URI deresolve(URI uri) {
// make sure references are stored without # URI prefix
return URI.createURI(uri.fragment());
}
};
resource.getDefaultSaveOptions().put(XMLResource.OPTION_URI_HANDLER, uriHandler);
resource.load(inputStream, null);