Forgive me because I know very little about EMF. I'm using a library named MDHT and am having an issue with it. This library has a class named org.openhealthtools.mdht.uml.cda.StrucDocText. That interface extends org.eclipse.emf.ecore.EObject. The StrucDocText has an addText method on it that takes a String.
My issue is that when org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl#saveElementFeatureMap is called, it escapes the text I'm adding in addText. Instead of escaping this String, I'd like it to save this String (but not others) as-is. When I look at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl#saveElementFeatureMap I don't see a path I can go down that gives me this option:
There's a switch for if (entryFeature == XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT). This looks like the right fit, but that escapes if an org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.Escape is provided. Is there an entryFeature I can give this to mean, "just use this String value without modification"?
MDHT already lets me do this but in an unacceptably inefficient way. Here's how it works:
Resource.Factory factory = new GenericXMLResourceFactoryImpl();
XMLResource resource = (XMLResource) factory.createResource(null);
resource.load(new URIConverter.ReadableInputStream("<text>" + xmlString + "</text>"), null);
XMLTypeDocumentRoot root = (XMLTypeDocumentRoot) resource.getContents().get(0);
AnyType value = (AnyType) root.getMixed().getValue(0);
text = CDAFactory.eINSTANCE.createStrucDocText();
text.getMixed().addAll(value.getMixed());
But I've already constructed this xmlString value as XML before I called addText. There is a serious performance hit to calling resource.load and text.getMixed().addAll. I need to avoid both if possible.