Announcement

Collapse
No announcement yet.

Fatal Error: Character reference "& #27" is an invalid XML character

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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.

    Comment


    • #3
      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 ?

      Comment


      • #4
        I am guessing your listener is setup to receive binary data. So you can apply the same thing inside a transformer on msg.
        HL7v2.7 Certified Control Specialist!

        Comment


        • #5
          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.

          Comment


          • #6
            @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, 06:00 AM.

            Comment


            • #7
              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?
              HL7v2.7 Certified Control Specialist!

              Comment


              • #8
                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

                Comment


                • #9
                  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.

                  Comment


                  • #10
                    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.

                    Comment

                    Working...
                    X