-
Notifications
You must be signed in to change notification settings - Fork 143
Open
Description
If you attempt to use the DefaultXmlParser
to encode a Message
which is a GenericMessage
, it will fail with a org.w3c.dom.DOMException
.
This is due to the presence of a $
within the ClassName of an instantiated GenericMessage
. Ex: GenericMessage$V23
.
Sample Test:
/**
* <p>
* Attempt to parse a {@link ca.uhn.hl7v2.model.GenericMessage}. These objects have `$` in their class name, ex: `GenericMessage$V21`.
* The {@link DefaultXMLParser} will attempt to use the class name when constructing the {@link Document} when encoding. The `$` is
* not a valid character within an element name.
* </p>
* <p>
* Construct a {@link GenericMessage} for each available version, and call {@link DefaultXMLParser#encode(Message)} on the message.
* We expect that a valid {@link Document} is returned, as the `$` is stripped out.
* </p>
*/
@Test
public void test_encode_GenericMessage() throws Exception {
DefaultXMLParser xmlParser = new DefaultXMLParser();
for (Version version : Version.values()) {
Class<? extends Message> c = GenericMessage.getGenericMessageClass(version.getVersion());
Message m = c.getConstructor(ModelClassFactory.class).newInstance(new GenericModelClassFactory());
Document d = xmlParser.encodeDocument(m);
Assert.assertNotNull(d);
Assert.assertEquals("GenericMessage" + version.name(), d.getDocumentElement().getTagName());
}
}
Will be submitting a PR with a workaround.
Metadata
Metadata
Assignees
Labels
No labels