|
Re: Is there a way to use a string as raw XML? [message #1240929 is a reply to message #1234430] |
Fri, 07 February 2014 08:36 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Dan,
Comments below.
On 22/01/2014 1:17 AM, Dan Kaplan wrote:
> 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.
It only escapes what needs to be escaped to produce well-formed XML, so
it's not clear what you're trying to produce...
> 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.
It sounds like you're trying to add as test content, a string that you
really want to be actual embedded XML tags... That's only possible if
the model itself allows that, but given I know nothing about
StrucDocText I can't say if it supports that. This article is likely
useful for understanding how that would be possible:
http://www.theserverside.com/news/1364302/Binding-XML-to-Java
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: Is there a way to use a string as raw XML? [message #1355300 is a reply to message #1354604] |
Wed, 14 May 2014 17:12 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Mathieu,
Comments below.
On 14/05/2014 3:19 PM, Mathieu Fossay wrote:
> Hi Dan,
> Have you finally solve your problem?
> I have the same issue:
> I have to generate a
> org.openhealthtools.mdht.uml.cda.ccd.ContinuityOfCareDocument object,
> and all works fine except the html text part storage.
How is that modeled?
> Like you, I had to fill a section with an html representation in the
> tag "<text>" of this content's section.
What's a "section"?
> And like you, the engine escape all the html tags presents in the
> String content added by the StrucDocText.addText method.
You need to create structured content if you want the structure serialized.
> Have you fix this issue in a simple way? and how?
Did you read the article I referenced?
>
> Thanks,
> Mathieu.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03887 seconds