how to handle invalid XML Characters

mercredi 25 mars 2015

Hi

Mirth 3.1.2

I am trying to extract a PDF document from xml message and write it to PDF file.

I built the following Channel



(1) Source connector types:

Inbound XML

Outbound Raw

Channel reader

I added a transformer step to the source connector to map the xml element to a variable as follows:

pdfdoc = msg['Body']['Part'][1]['Content'].toString();

globalChannelMap.put('pdfdoc',pdfdoc)



(2) Destination connector types:

Inbound Raw

Outbound Raw

File writer

File Type: Binary



I used the above variable in the destination template as follows:

${pdfdoc}



The problem:

the pdf has special characters and I keep getting the following error at the source transformer step:

Transformer error

ERROR MESSAGE: Error evaluating transformer

com.mirth.connect.server.MirthJavascriptTransforme rException:

CHANNEL: XDSb Retrieve Document Filter DOC

CONNECTOR: sourceConnector

SCRIPT SOURCE:

SOURCE CODE:

257: }

258: if ('xml' === typeof msg && msg.hasSimpleContent()) { msg = msg.toXMLString(); }if ('xml' === typeof tmp && tmp.hasSimpleContent()) { tmp = tmp.toXMLString(); }

259: }

260: if (doFilter() == true) { doTransform(); return true; } else { return false; }

261: }

LINE NUMBER: 262

DETAILS: TypeError: Character reference "" is an invalid XML character.

at 264932c5-eb67-4a90-b549-071d8ac1ec55:241 (doScript)

at 264932c5-eb67-4a90-b549-071d8ac1ec55:262

at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.call(JavaScr iptFilterTransformer.java:153)

at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.call(JavaScr iptFilterTransformer.java:118)

at java.util.concurrent.FutureTask.run(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)

at java.lang.Thread.run(Unknown Source)






My trials:

(1) if I remove the special characters in the preprocessor scirpt, I end up with corrupted PDF.

(2) if i change file type in my destination to "Text", I will have a PDF file the opens as blank



P.S: I attached samples from the xml message and the PDF document that should be extracted from this message.

Any help is mostly appreciated




Attached Files









File Type: pdf forcare.pdf (60.9 KB)
File Type: xml forcareMsg.xml (63.1 KB)







how to handle invalid XML Characters

0 commentaires:

Enregistrer un commentaire