web stats
Fatal Error: Character reference "& #27" is an invalid XML character - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-30-2017, 04:26 PM
vlad vlad is offline
What's HL7?
 
Join Date: Nov 2016
Posts: 1
vlad is on a distinguished road
Default Fatal Error: Character reference "& #27" is an invalid XML character

Hi!

I'm getting these errors when receiving MR DICOM files:

Code:
DICOMSerializer error
ERROR MESSAGE: Error converting DICOM to XML
java.lang.NullPointerException

ERROR: Error converting message or evaluating filter/transformer

ERROR (com.mirth.connect.model.converters.DocumentSerializer:112): org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 12854; Character reference "&#27" is an invalid XML character.

[Fatal Error] :1:12854: Character reference "&#27" is an invalid XML character.
The error seems to be that special ESC (ASCII 27) is breaking the parser. When the errors happen, the messages stay untransformed but when attachments are viewed, DICOM Image Viewer shows image previews normally.

It's on Mirth Connect Server 3.4.2.8129, Java 8. The channel is fairly simple which just receives DICOM and stores the locally. I traced the error to one of the tags having ESC character in it. The tag's VR type is LT. According to DICOM Part 5 ESC is a valid character for this type of value.

Is there a way to work around the issue?

Thank you!

Vlad
Reply With Quote
  #2  
Old 02-13-2017, 02:31 AM
robrud robrud is offline
Mirth Newb
 
Join Date: Oct 2015
Posts: 12
robrud is on a distinguished road
Default Remove invalid xml

Did you try the Codesniped "Remove Illegal XML Characters" in preprocessor?
return message.replace(/[\x00-\x08]|[\x0B-\x0C]|[\x0E-\x1F]/g, '');

Of course this manipulates the original message but we use that for channels expecting an XML message and where the sending application puts user free text content directly to the XML message.
Reply With Quote
  #3  
Old 05-05-2017, 04:29 AM
fluancefg fluancefg is offline
OBX.2 Kenobi
 
Join Date: Oct 2013
Posts: 83
fluancefg is on a distinguished road
Default

I have exactly the same problem.

I've tried the code to remove XML illegal characters, but it doesn't work because the raw data is binary, so it doesn't replace anything.

In that case, how can we remove illegal characters before it is transformed to XML ?
Reply With Quote
  #4  
Old 05-05-2017, 05:06 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

I am guessing your listener is setup to receive binary data. So you can apply the same thing inside a transformer on msg.
Reply With Quote
  #5  
Old 05-05-2017, 05:36 AM
fluancefg fluancefg is offline
OBX.2 Kenobi
 
Join Date: Oct 2013
Posts: 83
fluancefg is on a distinguished road
Default

Ok, I have found that there's an issue open: http://www.mirthcorp.com/community/i...wse/MIRTH-3127

For now my only current solution is to vote for the issue.
Reply With Quote
  #6  
Old 05-05-2017, 05:43 AM
fluancefg fluancefg is offline
OBX.2 Kenobi
 
Join Date: Oct 2013
Posts: 83
fluancefg is on a distinguished road
Default

@siddharth

For me the exception happens directly in the source.

Code:
ERROR (com.mirth.connect.model.converters.DocumentSerializer:112): org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 5; Character reference "&#1" is an invalid XML character.
ERROR (Server:143): [Fatal Error] :17:5: Character reference "&#1" is an invalid XML character.

Last edited by fluancefg; 05-05-2017 at 06:00 AM.
Reply With Quote
  #7  
Old 05-05-2017, 05:57 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

I am guessing the connectorMessage is in binary format, and this is being used inside a Transformer.

Did you try using xmlmsg=xmlmsg.replace(/[\x00-\x08]|[\x0B-\x0C]|[\x0E-\x1F]/g, '');

at the very next line?
Reply With Quote
  #8  
Old 05-05-2017, 06:10 AM
fluancefg fluancefg is offline
OBX.2 Kenobi
 
Join Date: Oct 2013
Posts: 83
fluancefg is on a distinguished road
Default

The problem is that I'm using the msg variable in the source transformer.

And when it tries to create that variable with XML content, the exception is thrown.

The error comes from the Serializer:

Code:
DICOMSerializer error
ERROR MESSAGE: Error converting DICOM to XML
java.lang.NullPointerException
Reply With Quote
  #9  
Old 07-20-2018, 07:06 AM
Kevin Carlin Kevin Carlin is offline
Mirth Newb
 
Join Date: Mar 2012
Posts: 22
Kevin Carlin is on a distinguished road
Default Has this issue been fixed yet?

I'm attempting to take one batch file (.zip) which is made up of multiple .txt files. These files have raw data within them and I'm running into a similar issue.

TypeError: An invalid XML character (Unicode: 0xf) was found in the element content of the document.

I saw the error ticket mentioned above but am wondering if any work has been done on this.
Reply With Quote
  #10  
Old 07-22-2018, 08:08 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 754
agermano is on a distinguished road
Default

That issue has to do with DICOM. If you're working with plain binary files, why are you trying to convert to XML? I recommend starting a new thread and giving a little more information about what you're trying to do.
Reply With Quote
Reply

Tags
dicom, error, invalid xml, transfomer

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 08:08 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation